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