I'm trying to populate textview inside tablerow but keep getting this error. I've tried with less than 4 textview inside row2 and it is working but more than 4 textview will throw the error.
Layout:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:id="@+id/stocklist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:clickable="true"/>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:id="@+id/stockinfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:clickable="true" />
</ScrollView>
Code:
TableLayout stcktable = (TableLayout)view.findViewById(R.id.stocklist);
TableLayout table = (TableLayout)view.findViewById(R.id.stockinfo);
for(int i=0;i < contacts.size();i++) {
try {
TableRow row=new TableRow(getActivity());
TextView tvDebt=new TextView(getActivity());
tvDebt.setText(contacts.get(i).getStockname());
tvDebt.setTextSize(12);
if (contacts.get(i).getStockStatus().equals("up")) {
tvDebt.setTextColor(getActivity().getResources().getColor(
R.color.textGreen));
} else if (contacts.get(i).getStockStatus().equals("down")) {
tvDebt.setTextColor(Color.RED);
} else if (contacts.get(i).getStockStatus().equals("nochange")) {
tvDebt.setTextColor(Color.GRAY);
}
tvDebt.setTypeface(ApplicationGlobles.roboto(getActivity()
.getApplicationContext()));
tvDebt.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
tvDebt.setPadding(25, 0, 0, 0);
tvDebt.setLayoutParams(new LayoutParams(
0, // TODO width
100,1f));
row.addView(tvDebt);
row.setLayoutParams(new LayoutParams(
TableRow.LayoutParams.MATCH_PARENT, // TODO width
TableRow.LayoutParams.WRAP_CONTENT)); // height);
row.setBackgroundResource(R.drawable.cell_shape);
stcktable.addView(row);
tvDebt=null;
System.gc();
} catch(Exception e) {
e.printStackTrace();
}
TableRow row2 = new TableRow(getActivity());
for(int j = 0; j < 6; j++) {
try {
TextView tv1=new TextView(getActivity());
tv1.setText(String.valueOf(contacts.get(i).getPrice()));
tv1.setTextSize(10);
tv1.setTypeface(ApplicationGlobles.roboto(getActivity()
.getApplicationContext()));
tv1.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
tv1.setTextColor(Color.BLACK);
tv1.setPadding(30, 0, 0, 0);
tv1.setLayoutParams(new LayoutParams(
0, // TODO width
100,1f));
tv1.setBackgroundResource(R.drawable.cell_shape2);
row2.addView(tv1);
tv1 = null;
System.gc();
} catch(Exception e) {
e.printStackTrace();
}
}
row2.setLayoutParams(new LayoutParams(
TableRow.LayoutParams.MATCH_PARENT, // TODO width
TableRow.LayoutParams.WRAP_CONTENT)); // height);
table.addView(row2);
}
Error:
03-21 19:16:18.216: A/libc(5472): new failed to allocate 65536 bytes
03-21 19:16:18.226: A/libc(5472): Fatal signal 6 (SIGABRT), code -6 in tid 5472 (sa.market.place)
0 comments:
Post a Comment