I have generated a ListView using SimpleAdapter. I am trying to display a tablerow on clicking the listview row. I want the TableRow to be displayed everytime I click a ListView row. I have done the following coding, but the TableRow masks or occupies the space of one of the ListView row below it, and secondly the Tablerow gets displayed only for the first row and not for the other rows. I am posting my codes below. Kindly help me step by step.
tasks extends Fragment
ListAdapter k=new SimpleAdapter(getActivity(),val,R.layout.senttaskdata,new String[]{"rname","heading","desc","id","path","receiver","sender"},new int[]{R.id.textView1,R.id.textView2,R.id.textView3,R.id.hide1,R.id.hide2,R.id.hide3,R.id.hide4})
{
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final View v = super.getView(position, convertView, parent);
//some codes here
return v;
}
};
sent.setAdapter(k);
sent.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
TableRow colors=(TableRow)arg0.findViewById(R.id.tableRow1);
RelativeLayout r=(RelativeLayout)arg0.findViewById(R.id.tasksent);
r.setVisibility(arg0.VISIBLE);
colors.setVisibility(arg0.VISIBLE);
}
});
my xml file for get the values into the List i.e senttaskdata
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/tasksent" >
<ImageView
android:id="@+id/mypicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="18dp"
android:layout_marginTop="24dp"
android:src="@drawable/border" />
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView3"
android:layout_marginTop="25dp"
android:visibility="invisible"
android:background="@android:color/black" >
<ImageView
android:id="@+id/imageView6"
android:layout_width="80dp"
android:layout_height="fill_parent"
android:background="@color/dblue"
android:src="@drawable/ic_status" />
</TableRow>
</RelativeLayout>
Use visiblity="GONE" then your view is not rendered and doesn't take place in your layout but you can reference it.