Anzeige AllIOsFragment überarbeiten
This commit is contained in:
parent
321707368f
commit
1332762ea0
@ -4,7 +4,12 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -15,31 +20,31 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import com.example.aped.R;
|
||||
|
||||
public class AllIOsFragment extends Fragment {
|
||||
/**Azeige Modell.*/
|
||||
private AllIOsViewModel allIOsViewModel;
|
||||
ListView lv;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param inflater
|
||||
* @param container
|
||||
* @param savedInstanceState
|
||||
* @return root
|
||||
*/
|
||||
public View onCreateView(final @NonNull LayoutInflater inflater,
|
||||
final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
allIOsViewModel =
|
||||
new ViewModelProvider(this).get(AllIOsViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_all_ios, container,
|
||||
false);
|
||||
final TextView textView = root.findViewById(R.id.text_all_IOs);
|
||||
allIOsViewModel.getText().observe(getViewLifecycleOwner(),
|
||||
new Observer<String>() {
|
||||
SearchView searchView;
|
||||
ArrayAdapter<String> adapter;
|
||||
String[] name = {"IN1", "Temperatur extern","Strom Heizung"};
|
||||
String[] data = {"IN1_", "Temperatur extern_","Strom Heizung_"};
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_all_ios, container,
|
||||
false);
|
||||
lv = (ListView) view.findViewById(R.id.idListView);
|
||||
adapter = new ArrayAdapter<String>(getActivity(),
|
||||
android.R.layout.simple_expandable_list_item_1,name);
|
||||
adapter = new ArrayAdapter<String>(getActivity(),
|
||||
android.R.layout.simple_expandable_list_item_2,data);
|
||||
lv.setAdapter(adapter);
|
||||
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onChanged(final @Nullable String s) {
|
||||
textView.setText(s);
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Toast.makeText(getContext(),"Position:"+position, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
return root;
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.all_IOs.AllIOsFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_all_IOs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<ListView
|
||||
android:id="@+id/idListView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user