tutorial tipos studio programacion personalizado español ejemplo edittext dialogos dialogo cuadro crear con android android-listview onclick progressdialog onclicklistener

tipos - manual de programacion android pdf



El diálogo de progreso no se muestra en el botón clic evento en listview (1)

Prueba este.

public class ImageAdapter extends BaseAdapter { private Context mContextL; public ImageAdapter(Context contextP) { mContextL = contextP; } public int getCount() { return ItemList.GetLength(); } public Object getItem(int PositionP) { return ItemList.GetObject(PositionP); } public long getItemId(int PositionP) { return PositionP; } class ViewHolder { Button btn1; TextView textView1; Spinner spQuantity; } public View getView(final int PositionP, View ConvertViewP, ViewGroup ParentP) { ViewHolder holder; if (ConvertViewP == null) { holder = new ViewHolder(); LayoutInflater inflater = (LayoutInflater) mContextL.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ConvertViewP = inflater.inflate(R.layout.add_cart_row_layout, ParentP, false); holder.textView1 = (TextView) ConvertViewP.findViewById(R.id.tvName); holder.spQuantity = (Spinner) ConvertViewP.findViewById(R.id.spQuantity); holder.btn1 = (Button) ConvertViewP.findViewById(R.id.btn1); ConvertViewP.setTag(holder); } else{ holder = (ViewHolder) ConvertViewP.getTag(); } holder.textView1.setText("asdfg"); holder.spQuantity.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> Parent, View view, int pos, long id) { ProgressDialog aProgressDialogL = new ProgressDialog(mContextL); aProgressDialogL.setMessage("Loading..."); aProgressDialogL.show(); //Processiing codes } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); ArrayAdapter<String> QuantityAdapter1 = new ArrayAdapter<String>(mContextL,android.R.layout.simple_spinner_item, QuantityList); QuantityAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); holder.spQuantity.setAdapter(QuantityAdapter1); holder.btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ProgressDialog aProgressDialogL = new ProgressDialog(activity1.this); aProgressDialogL.setMessage("Loading..."); aProgressDialogL.show(); } }); return ConvertViewP; } }

Tengo un botón en cada elemento de la lista de la vista de lista. En ese botón, haga clic en evento tengo algunos códigos para ejecutar. En evento de clic estoy mostrando el cuadro de diálogo de progreso antes de ejecutar el código. pero no se muestra. Después de que se completen todos los códigos en el evento de clic, al final se muestra el cuadro de diálogo de progreso. Por favor ayudame.

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity1); TheListViewM = (ListView) findViewById(R.id.lvItems); ImageAdapter anImageAdapterM =new ImageAdapter(this); TheListViewM.setAdapter(anImageAdapterM); } public class ImageAdapter extends BaseAdapter { private Context mContextL; public ImageAdapter(Context contextP) { mContextL = contextP; } public int getCount() { return ItemList.GetLength(); } public Object getItem(int PositionP) { return ItemList.GetObject(PositionP); } public long getItemId(int PositionP) { return PositionP; } public View getView(final int PositionP, View ConvertViewP, ViewGroup ParentP) { if (ConvertViewP == null) { LayoutInflater inflater = (LayoutInflater) mContextL.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ConvertViewP = inflater.inflate(R.layout.add_cart_row_layout, ParentP, false); } TextView textView1 = (TextView) ConvertViewP.findViewById(R.id.tvName); textView1.setText("asdfg"); final Spinner spQuantity = (Spinner) ConvertViewP.findViewById(R.id.spQuantity); spQuantity.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> Parent, View view, int pos, long id) { ProgressDialog aProgressDialogL = new ProgressDialog(mContextL); aProgressDialogL.setMessage("Loading..."); aProgressDialogL.show(); //Processiing codes } } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); ArrayAdapter<String> QuantityAdapter1 = new ArrayAdapter<String>(mContextL,android.R.layout.simple_spinner_item, QuantityList); QuantityAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spQuantity.setAdapter(QuantityAdapter1); Button btn1 = (Button) ConvertViewP.findViewById(R.id.btn1); btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ProgressDialog aProgressDialogL = new ProgressDialog(activity1.this); aProgressDialogL.setMessage("Loading..."); aProgressDialogL.show(); } }); return ConvertViewP; }