mardi 26 mai 2015

ListView item button action

**i am trying to press the button in list item then the calories of this item will be added on a circular progress bar and the table will be disabled but the progress increase only when i press one button then stop also another button is disabled not the pressed button .

public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.meal_layout, parent,false);
        meal = MealList.get(position);
        TextView cal = (TextView)view.findViewById(R.id.calories);
        TextView desc= (TextView) view.findViewById(R.id.desc);
        TextView title = (TextView) view.findViewById(R.id.title);
        add = (Button) view.findViewById(R.id.button1);
        cal.setText("سعرة"+meal.getCalories());
        desc.setText(meal.getDescription());
        title.setText(meal.getTitle());

    add.setOnClickListener(new OnClickListener() {






            @Override
            public void onClick(View v) {
                calories = Integer.parseInt(meal.getCalories());
                add.setEnabled(false);




            }
        });

        return view;


}*

then the progress activity

  public class ProgressActivity extends Activity{
    ProgressBar pb;
    int percent;
    Double BMR;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result_layout);
        pb = (ProgressBar) findViewById(R.id.progressBarToday);
    /*Bundle extras = getIntent().getExtras();
        if (extras != null) {
           BMR = extras.getDouble("BMR");}*/
        percent = (int) ((Cadapter.calories/10));
        pb.setProgress(pb.getProgress()+percent);

    }

}*

Aucun commentaire:

Enregistrer un commentaire