puede hacerlo de esta manera:
dentro de la disposición de las hileras xml listview matriz añadir la siguiente disposición de la tabla
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/table_show"
android:background="#beb4b4">
</TableLayout>
entonces usted tiene que hacer un diseño para la lista de elementos secundarios con el nombre reply_row.xml
<?xml version="1.0" encoding="utf-8"?>
<TableRow android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tv_reply_row"
android:textColor="#000"/>
</TableRow>
en su método getView adaptador de vista de lista padre agregue el código siguiente:
TableLayout replyContainer = (TableLayout)
// vi is your parent listview inflated view
vi.findViewById(R.id.table_show);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//child listview contents list
String [] replys = {"a","b","c","d"};
for (int i=0;i<replys.length;i++)
{
final View comments = inflater.inflate(R.layout.reply_row, null);
TextView reply_row = (TextView) comments.findViewById(R.id.tv_reply_row) ;
reply_row.setText(replys[i]);
//for changing your tablelayout parameters
TableLayout.LayoutParams tableRowParams=new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
int leftMargin=3;
int topMargin=2;
int rightMargin=3;
int bottomMargin=2;
tableRowParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
comments.setLayoutParams(tableRowParams);
TableRow tr = (TableRow) comments;
replyContainer.addView(tr);
}
El listener a la lista no funciona con esto. ¿Alguna solución? –
Gracias amigo. Es una gran idea. –
Deseo implementar la lista Dentro de la Lista pero no puedo Implementar. ¿Existe alguna Alternativa para resolver este problema? Excepto ListView expansible – seon