How can I embed my listview in a layout that I have already created? For example in my_layout.xml I have something like:
<linear layout>
<textview>
<*my list view goes here*>
<linear layout>
I created a List Activity like so:
public class HelloListView extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
}
}
Thanks!
your xml my_layout.xml:
<linear layout>
<textview>
<ListView android:id="@+id/list"
android:layout_height="match_parent"
android:layout_width="match_parent"
>
</ListView>
<linear layout>
and your java file:
public class HelloListView extends Activity { // not use ListActivity
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
ListView lv = (ListView) this.findViewById(R.id.list);
// make something for List adapter
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));
lv.setTextFilterEnabled(true);
}
}
hope helping you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With