-2

我有一个列表视图,它显示 4 个项目(id、类型、位置和价格)。单击列表视图中的某个项目后,我试图显示更多项目。

这是我的桌子

static final String DATABASE_CREATE2 = "create table "+data+ "( " +data_id+" integer primary key autoincrement," + "TITLE text,TYPE text,LOCATION text, PRICE text, ADDRESS text, DESCRIPTION text); ";

下面是列表视图

listContent = (ListView)findViewById(R.id.ListViewId);
  mySQLadapter = new DatabaseAdapter(this);
  mySQLadapter.openToWrite();
  cursor = mySQLadapter.queueAll5();


  String[] from = new String[]{DatabaseAdapter.data_id,DatabaseAdapter.type, DatabaseAdapter.location,DatabaseAdapter.price};
  int[] to = new int[]{R.id.getId2,R.id.getType,R.id.getLocation,R.id.getPrice};

  cursorAdapter =
   new SimpleCursorAdapter(this, R.layout.roomdetails_list2, cursor, from, to);
  listContent.setAdapter(cursorAdapter);

例如,在表中,已经存储了一组数据。

id 1, title halo, type condo, location kl, price 200, address bukit bintang, description good

在 listview 上只显示 id、type、location、price。但现在我想点击它并在下一个活动中显示整行。我应该如何处理查询?条件如何?

4

1 回答 1

0

你的意思是一旦你点击一行。一个新的活动开始了,它包含了关于row

list = (ListView) findViewById(R.id.vmf_items_list);   
list.setOnItemClickListener(LstListener);

private OnItemClickListener LstListener = new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        @SuppressWarnings("unchecked")
        Object ob= list.getItemAtPosition(position);

        Log.i(Tag, "DisplayID:" + ob.toString());
        //calling the next activity 
        Intent intent = new Intent(Activity.this, Activity2.class);
        intent.putExtra("DisplayID", o.get(KEY_SVBID));
        startActivity(intent);

    }
};
于 2013-06-02T05:56:58.190 回答