I have two button at bottom i.e after listview ends.

I am using a custom listview which display list items with alternate colors.

[![](https://i.stack.imgur.com/Yn98e.png)](https://i.stack.imgur.com/Yn98e.png)

how to set setOnClickListener for both button at bottom?

```
public class PieMainActivity extends Activity  {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mRes = getResources();
    new Random(new Date().getTime());

    solbtn = (Button)findViewById(R.id.solution);

    String recive ;

    Bundle b = getIntent().getExtras();
    final int piewrong=b.getInt("piewrong");
    final int pieright=b.getInt("pieright");
    final int pieunclick=b.getInt("pieunclick");

    setContentView(R.layout.piechart_result);

    recive = pieright+"/20";
    mPie.setUnit(recive);

    data1 = new ArrayList<String>();
    fillData() ;

    listtotal =getIntent().getStringArrayListExtra("listtotal");
    timeuse =getIntent().getStringArrayListExtra("timeused");

    adapter1 = new ListAdapter(this, data1, listtotal,timeuse);
    ListView lvMain = (ListView) findViewById(R.id.list);
    lvMain.setAdapter(adapter1);

    lvMain.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // TODO Auto-generated method stub
             int questionno = position+1;

                Bundle b = new Bundle();                
                b.putInt("questionno",questionno);
                b.putInt("piewrong",piewrong);
                b.putInt("pieright",pieright);
                b.putInt("pieunclick",pieunclick);
                Intent in=new Intent(PieMainActivity.this,Solution.class);
                in.putStringArrayListExtra("listtotal", (ArrayList<String>) listtotal);
                in.putStringArrayListExtra("timeused", (ArrayList<String>) timeuse);
                in.putExtras(b); 
                startActivity(in);
                finish();

        }
    });

}
void fillData() {
    for (int i = 1; i <= 20; i++) {
        data1.add("Question " + i);
    }
}
void fillcmp() {
    for (int i = 1; i <= 20; i++) {
        cmp.add("cmp " + i);
    }
}
}

```

xml file

```
<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/com.staritsolutions.apptitude"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"

android:orientation="vertical" >
 <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:orientation="vertical"
           android:layout_marginLeft="10dp"
           android:layout_marginRight="10dp"
           android:layout_marginTop="5dp" 
           android:layout_weight="1.0">
 <ListView
    android:id="@+id/list"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
         >
      </ListView>

  </LinearLayout>

  <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="40dp"
           android:layout_marginBottom="10dp"
           android:layout_marginTop="5dp"
           android:orientation="horizontal"
           android:layout_marginLeft="10dp"
           android:layout_marginRight="10dp">

       <Button
         android:id="@+id/home"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:layout_gravity="bottom|center_horizontal"
         android:layout_marginLeft="6dp"
         android:layout_marginRight="3dp"
         android:textSize="12dp"
         android:layout_weight="1"
         android:clickable="true"
         android:gravity="center"

         android:text="Main Menu"
         android:background="@drawable/btn_blue" 
         android:textColor="#fff"
         android:textStyle="bold" />

    <Button
         android:id="@+id/solution"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:layout_gravity="bottom|center_horizontal"
         android:layout_marginLeft="6dp"
         android:layout_marginRight="3dp"
         android:textSize="12dp"
         android:layout_weight="1"
         android:clickable="true"
         android:gravity="center"

         android:text="Solutions"
         android:background="@drawable/btn_blue" 
         android:textColor="#fff"
         android:textStyle="bold" />
</LinearLayout>

</LinearLayout>

```

BaseAdapter file

```
public class ListAdapter extends BaseAdapter{
Context ctx;
LayoutInflater lInflater;
List<String> data1;
List<String> cmp;
List<String> timeused;

ListAdapter(Context context, List<String> data1 ,List<String> cmp ,List<String> timeused) {
    ctx = context;
    this.data1 = data1;
    this.cmp = cmp;
    this.timeused = timeused;
    lInflater = (LayoutInflater) ctx
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount() {

    return data1.size();
}
public int getCount1() {
    return cmp.size();
}

@Override
public Object getItem(int position) {
    return data1.get(position);
}
public Object getItem1(int position1) {
    return cmp.get(position1);
}

@Override
public long getItemId(int position) {
    return position;
}
public long getItemId1(int position1) {
    return position1;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
        view = lInflater.inflate(R.layout.listitem, parent, false);
    }
    /*if (position % 2 == 0) {
        view.setBackgroundResource(R.drawable.artists_list_backgroundcolor);
    } else {
        view.setBackgroundResource(R.drawable.artists_list_background_alternate);
    }*/
    TextView text = (TextView) view.findViewById(R.id.heading);
    int no = position;
    if(cmp.get(position).equals("GREEN"))
    {
        text.setTextColor(Color.parseColor("#00D50E"));
    }else if(cmp.get(position).equals("RED"))
    {
        text.setTextColor(Color.parseColor("#e84040"));
    }else
    {
        text.setTextColor(Color.parseColor("#B441E9"));
    }

    ((TextView) view.findViewById(R.id.heading)).setText(data1.get(position));
    ((TextView) view.findViewById(R.id.duration)).setText(timeused.get(position));
    return view;
    //String.valueOf(value);
 }
}

```