2012-01-20 7 views
0

私は画像に示すような複数列リストビューを持って、私は質問list.soこのカスタムを移入するためのカスタム・アダプターを使用し、私は送信ボタンをクリックすると、送信ボタンをクリックするだけでデータを取得することを意味する方法であります私は事前にのみ確認され、チェックボックス....ありがとうの名称、価格や数量などのデータを取得する必要があります。私の主なXMLでAndroidの動的な複数列リストビュー

私は、リストビューを持っているとmainlist XMLで私はtxtname、txtprice、のEditTextとチェックボックスがあり、効率的なアダプタを使用します。 リストビューでデータを表示できません。問題は、送信ボタンのクリックでデータを保存できません...したがって、PLZは、サンプルコード、アンドロイドに新しいbcz mを手助けします..

次は私のコード..です

public class Menu extends Activity { 
ListView list; 
Cursor cursorMenu; 
Button btnPlaceOrder; 
Button btnShowOrders; 
String Descstr=""; 
String strtotal=""; 

List<String[]> lstSelectedItems = null; 


DBAdapter db = new DBAdapter(this); 


private String[] strName; 
private String[] strPrice; 
private String[] strDescription; 

private class EfficientAdapter extends BaseAdapter { 
    private LayoutInflater mInflater; 


    public EfficientAdapter(Context context) { 
     mInflater = LayoutInflater.from(context); 
    } 

    public int getCount() { 

     try { 
      return strName.length; 
     } catch (Exception e) { 
      //Toast.makeText(Menu.this, "No Data !", Toast.LENGTH_LONG).show(); 
      return 0; 
     } 

    } 

    public Object getItem(int position) { 
     return position; 
    } 

    public long getItemId(int position) { 
     return position; 
    } 

    public View getView(int position, View convertView, ViewGroup parent) { 
     final ViewHolder holder; 
     if (convertView == null) { 
      convertView = mInflater.inflate(R.layout.menulist, null); 

      holder = new ViewHolder(); 
      holder.text = (TextView) convertView 
        .findViewById(R.id.txtItemName); 
      holder.text2 = (TextView) convertView 
        .findViewById(R.id.txtPrice); 
      holder.text3 = (TextView) convertView 
        .findViewById(R.id.txtDescription); 
      holder.etext3 = (EditText) convertView 
        .findViewById(R.id.txtQty); 
      holder.chk = (CheckBox) convertView 
        .findViewById(R.id.chkBox); 



      convertView.setTag(holder); 
     } else { 
      holder = (ViewHolder) convertView.getTag(); 
     } 

     holder.text.setText(strName[position]); 
     holder.text2.setText(strPrice[position]); 
     holder.text3.setText(strDescription[position]); 
     return convertView; 
    } 

    class ViewHolder { 
     TextView text; 
     TextView text2; 
     TextView text3; 
     EditText etext3; 
     CheckBox chk; 

    } 
} 

public void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 
    setContentView(R.layout.menu); 

    btnPlaceOrder = (Button) findViewById(R.id.btnPlaceOrder); 
    btnPlaceOrder.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 


     } 
    }); 


    /*db.open(); 
    cursorMenu = db.menu_getAllTitles(); 

    int rowcount = cursorMenu.getCount(); 

    System.out.println("---- +++++ " + rowcount); 
    System.out.println("---- column +++++ " + cursorMenu.getColumnCount()); 

    int index = 0; 
    if (rowcount > 0) { 
     strName = new String[rowcount]; 
     strPrice = new String[rowcount]; 
     strDescription = new String[rowcount]; 
     if (cursorMenu.moveToFirst()) { 
      do { 

       strName[index] = cursorMenu.getString(1); 
       strDescription[index] = cursorMenu.getString(2); 
       strPrice[index] = cursorMenu.getString(3); 
       Log.v(TAG, "Name-- " + strName[index] + "Price-- " 
         + strPrice[index]); 
       index++; 
      } while (cursorMenu.moveToNext()); 
     } 
     cursorMenu.close(); 

    } else { 
     Toast.makeText(this, "No Data found", Toast.LENGTH_LONG).show(); 
    }*/ 




    list = (ListView) findViewById(R.id.lstMenu); 
    list.setAdapter(new EfficientAdapter(this)); 
    System.out.println("--List Child count-----"+list.getChildCount()); 
    System.out.println("--List count-----"+list.getCount()); 

    list.setOnItemClickListener(new OnItemClickListener() { 

     @Override 
     public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, 
       long arg3) { 
      Toast.makeText(getBaseContext(), 
        "You clciked " + strName[arg2] + "\t" + strPrice[arg2], 
        Toast.LENGTH_LONG).show(); 

     } 
    }); 

} 

}

答えて

関連する問題