Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Breakfast extends Activity{
- ListView mylistview;
- ArrayAdapter<String> listAdapter;
- TextView display;
- public int counter = 0;
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.breakfast);
- display = (TextView) findViewById(R.id.tvDisplay);
- mylistview = (ListView)findViewById(R.id.listView1);
- final int[] caloriesBreakfast = getResources().getIntArray(R.array.caloriesBreakfas_array);
- final String[] mealsBreakfast = getResources().getStringArray(R.array.mealsBreakfast_array);
- listAdapter = new ArrayAdapter<String>(this, R.layout.listitem, mealsBreakfast);
- mylistview.setAdapter(listAdapter);
- //For ListItem Click
- mylistview.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView<?> arg0, View arg1, int position,
- long arg3) {
- int calories = caloriesBreakfast[position];
- Intent intent= getIntent();
- int counter = intent.getIntExtra("key", 0);
- // msg += ", Added at Third"; HOW TO ADD CURRENT RESULT HERE?
- counter += calories;
- display.setText("Result: " + counter);
- intent.putExtra("currentresult", counter);
- setResult(RESULT_OK, intent);
- finish();
- }
Add Comment
Please, Sign In to add comment