У меня есть одно действие, в котором я пытаюсь показать несколько простых сообщений, а затем список элементов. Итак, как я понимаю, мне нужны два представления: одно для простого макета, а другое для списка элементов, которые будут обрабатываться адаптером.
Вот мой код:
ArrayAdapter<SolutionTopic> adapter;
ArrayList<SolutionTopic> problems = new ArrayList <SolutionTopic>( );
/ ** Вызывается при первом создании действия. * /
@Override
public void onCreate (BundlevedInstanceState)
{
super.onCreate (savedInstanceState);
// Load your layout
setContentView(R.layout.solution);
SolutionTopic s = new SolutionTopic ();
s.setSolutionTopicName( "Hello" );
problems.add(s);
adapter = new ArrayAdapter<SolutionTopic>(this, R.layout.solution_topic_list,
R.id.label, problems);
TextView solution_title = (TextView) findViewById(R.id.solution_title);
TextView solution_description = (TextView) findViewById(R.id.solution_description);
setListAdapter (adapter);
}
и вот решение.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/solution_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Label1"
/>
<TextView
android:id="@+id/solution_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Label2"
/>
</LinearLayout>
и вот решение_topic_list.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
Что я не уверен, так это как заставить эти два визуализировать вместе. В идеале я хочу сначала отобразить сообщения TextView, а затем список элементов.
Есть идеи, как мне это сделать?
Спасибо!