activity_main.xml
does not have Button
with id mytask
. So you cannot initialize Button in MainActivtiy.
The Button
belongs to mytask.xml
override getView and have the button listener there.
http://developer.android.com/reference/android/widget/SimpleAdapter.html
Edit:
SimpleAdapter k=new SimpleAdapter(this,val1,R.layout.mytask,new String[]{"a","c","b"},new int[]{R.id.View1,R.id.View2,R.id.ViewStatus})
{
@Override
public View getView (int position, View convertView, ViewGroup parent)
{
View v = super.getView(position, convertView, parent);
Button b=(Button)v.findViewById(R.id.mytask);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this,"save",Toast.LENGTH_SHORT).show();
}
});
return v;
}
};
Edit: Since you are not convinced here's the snap