I think that the program keeps crashing because of this
public class ViewAll extends Activity {
TableLayout t;
MyDBManager d;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_all);
t = (TableLayout)findViewById(R.id.TableLayout1);
d = new MyDBManager(ViewAll.this);
Inflated();
}
private void Inflated()
{
Item[] items = d.GetAllItemsArray();
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row;
Button buttonInfo;
TextView priceInfo;
TextView itemInfo;
for (int i=0;i<items.length; i++)
{
row = vi.inflate(R.layout.onetask, null); //Here lies the problem
itemInfo = (TextView) row.findViewById(R.id.textView1);
priceInfo = (TextView) row.findViewById(R.id.textView2);
itemInfo.setText(items[i].getName());
priceInfo.setText(items[i].getPrice());
buttonInfo = (Button) row.findViewById(R.id.button1);
buttonInfo.setTag(items[i].getId() + "");
buttonInfo.setOnClickListener(l);
t.addView(row);
}
}
OnClickListener l = new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ViewAll.this, v.getTag().toString(),Toast.LENGTH_LONG).show();
Intent i = new Intent(ViewAll.this, UpdateItems.class);
i.putExtra("itemid", v.getTag().toString());
startActivity(i);
}
};
@Override
public boolean onCreateOptionsMenu(Menu menu) {enter code here
getMenuInflater().inflate(R.menu.view_all, menu);
return true;
}
}