How Can we add Image in List View
package im.li;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class ImagelistviewActivity extends ListActivity {
/** Called when the activity is first created. */
String name[]={"Rahul","aju","Vivek","Binnesh","Rehu"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
ArrayAdapter<String> a=new ArrayAdapter<String>(this, R.layout.main, R.id.offerdetails,name);
setListAdapter(a);
}
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Intent i=new Intent(this,second.class);
startActivity(i);
}
}
--------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_centerInParent="true"
android:id="@+android:id/offerdetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/icon" android:layout_width="65dp" android:layout_height="65dp" android:src="@drawable/icon" android:layout_x="238dp" android:layout_y="10dp"></ImageView>
</AbsoluteLayout>
No comments :
Post a Comment