Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ImageView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/arrow"
- android:layout_alignParentRight="true"
- android:onClick="btnclick"
- android:layout_centerVertical="true"/>
- How can I make this to be different, like ItemClickListener with position?
- class DAdapter extends ArrayAdapter<String>{
- Context context;
- int [] images;
- String[] titleArray;
- DAdapter(Context c, String [] titles, int imgs[])
- {
- super(c,R.layout.single_row, R.id.title,titles);
- this.context=c;
- this.images=imgs;
- this.titleArray=titles;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View row=convertView;
- if (row==null) { LayoutInflater inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- row=inflater.inflate(R.layout.single_row, parent,false);
- }
- ImageView myImage=(ImageView) row.findViewById(R.id.list_image);
- TextView myTitle=(TextView) row.findViewById(R.id.title);
- myImage.setImageResource(images[position]);
- myTitle.setText(titleArray[position]);
- return row;
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/list_selector"
- android:orientation="horizontal"
- android:padding="5dip" >
- <LinearLayout android:id="@+id/thumbnail"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="3dip"
- android:layout_alignParentLeft="true"
- android:background="@drawable/image_bg"
- android:layout_marginRight="5dip">
- <ImageView
- android:id="@+id/list_image"
- android:layout_width="50dip"
- android:layout_height="50dip"
- android:src="@drawable/ic_launcher"/>
- </LinearLayout>
- <TextView
- android:id="@+id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignTop="@+id/thumbnail"
- android:layout_toRightOf="@+id/thumbnail"
- android:text=""
- android:textColor="#040404"
- android:typeface="sans"
- android:textSize="15sp"
- android:textStyle="bold"/>
- <ImageView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/arrow"
- android:layout_alignParentRight="true"
- android:onClick="btnclick"
- android:layout_centerVertical="true"/>
- </RelativeLayout>
- <ImageView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/arrow"
- android:layout_alignParentRight="true"
- android:id="@+id/arrowImage"
- android:onClick="btnclick"
- android:layout_centerVertical="true"/>
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View row = convertView;
- if (row == null) {
- LayoutInflater inflater = (LayoutInflater) context
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- row = inflater.inflate(R.layout.single_row, parent, false);
- }
- ImageView myImage = (ImageView) row.findViewById(R.id.list_image);
- TextView myTitle = (TextView) row.findViewById(R.id.title);
- myImage.setImageResource(images[position]);
- myTitle.setText(titleArray[position]);
- ImageView arrowImage = (ImageView) row.findViewById(R.id.arrowImage);
- arrowImage.setTag(position);
- arrowImage.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- int clickedposition=(Integer) v.getTag();
- //Write your Activity launch code here..
- }
- });
- return row;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement