单击listview后显示数据

时间:2013-06-02 05:38:51

标签: android listview onclicklistener

我有一个列表视图,显示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
列表视图上的

仅显示ID,类型,位置,价格。但现在我想点击它在下一个活动上显示整行。该怎么办查询?条件怎么样?

1 个答案:

答案 0 :(得分: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);

    }
};