-2

我想在我的 ListView 的第一行中获取 editText 的值,谁能告诉我该怎么做。我正在尝试这个,但它不起作用。

      View v = (View) S_4th_SelectItem.lst_listOrder.getChildAt(0);
      myHolder.txt_Qty = (EditText) v.findViewById(R.id.txt_QTY);
      String qty = myHolder.txt_Qty.getText().toString();
      myHolder.txt_Qty.setClickable(false);
4

1 回答 1

0

试试这个它可以正常工作。

Database file:



     String strcol[] = new String[] { "Date1", "Time", "Title" };

public ArrayList<HashMap<String, String>> retrieve() {
ArrayList<HashMap<String, String>> ar = new ArrayList<HashMap<String, String>>();
    try {
        Cursor c = db.query("LOGIN", strcol, null, null, null, null, null);
        c.moveToNext();
        while (!c.isAfterLast()) {
            String dat = c.getString(0);
            String tim = c.getString(1);
            // String due=c.getString(2);
            // String end=c.getString(3);
            // String cat=c.getString(4);
            // String not=c.getString(5);
            String titl = c.getString(2);
    HashMap<String, String> hmap = new HashMap<String, String>();
            hmap.put("date", dat);
            hmap.put("time", tim);
            hmap.put("title", titl);
            ar.add(hmap);
            c.moveToNext();

        }
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
    Log.e("Check ar size at ret", "" + ar.size());
    return ar;
}

在这个文件中,我创建了用户定义方法,我在其中放置了值。

.javafile(在列表视图中获取数据)-:

public class List_activity extends Activity {
Login_database login_database;
ListView lv;
 Dialog listDialog;
ArrayList<HashMap<String, String>> al;
Button btn1,btn2,edt_data;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_view1);
    edt_data=(Button)findViewById(R.id.btn_edt_data);
    edt_data.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

        }
    });

    try 
    {
        login_database=new Login_database(this);
        login_database.open();

    }
    catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
    try {
        al=login_database.retrieve();
   ListAdapter ld=new SimpleAdapter(List_activity.this, al, R.layout.list_view, new String[]{"date","time","title"}, new    int[]{R.id.listDesignTxtDate,R.id.listDesignTxtTime,R.id.listDesignTxtTitle});
     ArrayAdapter ad=new ArrayAdapter(List_activity.this, new R.layout.list_view,R.id.listDesignTxt,al);
        lv=(ListView)findViewById(R.id.lv1);
        lv.setAdapter(ld);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }     
于 2013-10-18T13:27:40.280 回答