【发布时间】:2015-04-30 10:20:15
【问题描述】:
我有一个带有表格布局的活动。我将文本从字符串数组放入布局中。但现在我收到错误:“无效方法无法返回值”
public class stop10 extends SherlockFragmentActivity {
String[] column1;
String[] column2;
View view;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.stop10);
TableLayout prices = (TableLayout)view.findViewById(R.id.table);
String[] column1 = getResources().getStringArray(R.array.column1);
String[] column2 = getResources().getStringArray(R.array.column2);
prices.setStretchAllColumns(true);
prices.bringToFront();
for(int i = 0; i < column1.length; i++){
TableRow tr = new TableRow(getApplicationContext());
TextView c1 = new TextView(getApplicationContext());
c1.setText(column1[i]);
TextView c2 = new TextView(getApplicationContext());
c2.setText(column2[i]);
tr.addView(c1);
tr.addView(c2);
prices.addView(tr);
}
return view;
}
我知道void方法不能返回值,但是我现在还应该使用什么?
提前致谢。
【问题讨论】:
-
如果上面写着
Void methods cannot return a value,那么你应该删除return view;。
标签: android methods tablelayout void