I want to implement ListView without extend listActivity, and I dont know how to implement it. I just cant do getListView(); because I am not extened from listActivity. can you give an example code the I will take care of the listview to do this -> lv.setAdapter(listAdapter)
my xml looks like that
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLa"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/iconremove"
android:layout_width="50dip"
android:layout_height="50dip"
android:scaleType="centerCrop"
android:src="@drawable/removeicon"
android:visibility="gone"
/>
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:textSize="20dip" />
</LinearLayout>
and my code:
public class ListRss extends SherlockActivity {
ActionBar actionbar;
@SuppressWarnings("unchecked")
public ArrayList<rssLinkAndTitle> ListRssLinkAndTitle=new ArrayList();
//public ArrayList listValue=new ArrayList();
RssArrays rssparser=new RssArrays();
Context con;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.titlesrss);
actionbar=getSupportActionBar();
con=getApplicationContext();
// ListRssAdpter listAdapter;
ListView lv = (ListView) findViewById(R.id.linearLa );
lv.setTextFilterEnabled(true);
lv.setAdapter(listAdapter)
Note that there is a
SherlockListActivitythat you can use.Correct. You need to call
setContentView()with the ID of a layout resource that contains aListView. Then, you can retrieve thatListViewviafindViewById(), the same as you would for any other widget.