Я застрял, я не понимаю, как реализовать ListView, находящийся внутри фрагмента, я пытаюсь сделать чат-гии.Фрагмент, содержащий настраиваемый ListView
Можно ли сделать что-то подобное или я полностью на ветру?
Спасибо за помощь! С уважением, новичок! ^^
Вот фрагмент кода:
public static class ChatFragment extends Fragment {
public ChatFragment() {
// Empty constructor required for fragment subclasses
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_chat, container, false);
/*FragmentManager fm = getActivity().getFragmentManager();
DataListFragment list = new DataListFragment();
fm.beginTransaction().add(R.id.list_message_History, list).commit();
*/
getActivity().setTitle(R.string.chat);
return rootView;
}
}
Но как у видеть я не udnerstand, как соединить все это. У меня есть настроенный ListFragment, который использует ArrayAdapter для обработки данных.
Вот мой файл макета:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@id/android:list"
android:orientation="horizontal">
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
</LinearLayout>
</LinearLayout>
вы должны сделать пользовательский адаптер для этого – Piyush
Что вы имеете в виду? – westberg
У меня есть класс ListFragment, который расширяет ListFragment, и этот класс использует настраиваемый класс ArrayAdapter. Но как мне привязать их к фрагменту? – westberg