For this we have to customize the layout instead of listview. it is not possible with listview because listview takes items so individual onclick methods developing is not possible.see the following code. it will help you alot.
Activity:
package com.example.customlistexample;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TableLayout.LayoutParams;
import android.widget.TextView;
public class SearchResults extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/** create a new layout to display the view */
final LinearLayout mainLinearLayout = (LinearLayout) findViewById(R.id.mainLinearLayout);
String listData[] = new String[]{"A","B","C","D","E","F","G"};
for (int i = 0; i < listData.length; i++) {
TextView tv1 = new TextView(this);
tv1.setText(listData[i]);
tv1.setLayoutParams(new LayoutParams(50,50,Gravity.LEFT));
tv1.setTextColor(Color.BLACK);
tv1.setTypeface(null, Typeface.BOLD);
tv1.setTextSize(TypedValue.COMPLEX_UNIT_PX, 22);
ImageView iv1 = new ImageView(this);
iv1.setLayoutParams(new LayoutParams(50, 50,Gravity.LEFT));
iv1.setImageResource(R.drawable.ic_launcher);
ImageView iv2 = new ImageView(this);
iv2.setImageResource(R.drawable.ic_launcher);
iv2.setLayoutParams(new LayoutParams(50,50,Gravity.LEFT));
final LinearLayout ll3 = new LinearLayout(this);
ll3.setOrientation(LinearLayout.HORIZONTAL);
ll3.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT,Gravity.CENTER_HORIZONTAL));
ll3.addView(tv1);
ll3.addView(iv1);
ll3.addView(iv2);
ll3.setPadding(0, 20, 0, 25);
mainLinearLayout.addView(ll3);
final LinearLayout ll5 = new LinearLayout(this);
ll5.setLayoutParams(new LayoutParams(1, 1));
ll5.setBackgroundColor(Color.parseColor("#CCCCCC"));
mainLinearLayout.addView(ll5);
mainLinearLayout.setPadding(10, 10, 10, 30);
iv1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(SearchResults.this,SecondActivity.class));
}
});
iv2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mainLinearLayout.removeView(ll3);
mainLinearLayout.removeView(ll5);
}
});
}
}
}
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SearchResults" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/mainLinearLayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:orientation="vertical">
<TextView
android:id="@+id/tv_results"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Results"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#800000"
android:textSize="22px"
android:textStyle="bold" >
</TextView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
try this definately helps you. Let me know your doubt is clarified or not.