나는 ListView
을 가지고 있는데, 다른 활동으로 가기 전에 먼저 항목을 선택 (강조 표시)하고 버튼을 클릭하고 싶습니다.단추를 클릭 한 후 ListView에서 선택한 항목을 실행하려면 어떻게해야합니까?
http://i46.tinypic.com/2rc7gw4.png
이 내가 (I 데이터베이스에서 해당 항목을 얻을)
ListView lv = (ListView) findViewById(R.id.lvListOfCustomers);
String strDBName = "db_customers.s3db";
File fileDB = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
strDBName);
SQLiteDatabase dbLibrary = SQLiteDatabase.openOrCreateDatabase(fileDB,
null);
// Start - Cursor and Queries of List of Customers(ListView)
String sqlQuery = "select _id, customer_name as cName, customer_address as cAddress, customer_status as cStatus from tbl_customers";
Cursor cur = (Cursor) dbLibrary.rawQuery(sqlQuery, null);
@SuppressWarnings("deprecation")
SimpleCursorAdapter sca = new SimpleCursorAdapter(
this.getApplicationContext(),
R.layout.lv_list_of_customers_txtview, cur, new String[] {
"cName", "cAddress", "cStatus" }, new int[] {
R.id.tvCustomersName, R.id.tvCustomersAddress,
R.id.tvCustomersId }, CursorAdapter.FLAG_AUTO_REQUERY);
lv.setAdapter(sca);
// End - Cursor and Queries of List of Customers(ListView)
// Start - Make the items highlighted
int selectedListItem = getIntent().getIntExtra("PositionInList", -1);
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lv.setSelection(selectedListItem);
// End - Make the items highlighted
을 내 ListView를 만들어 어떻게이 무엇을이다 : 여기
내가 뭘 원하는지의 예 나는 내 버튼을 만들었습니다.case R.id.bCallRemarks:
// TODO Auto-generated method stub
Button bCRemarks = (Button) findViewById(R.id.bCallRemarks);
bCRemarks.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ListView.OnItemClickListener oicl = new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> av, View view,
int pos, long id) {
// TODO Auto-generated method stub
Cursor c = (Cursor) av.getItemAtPosition(pos);
String cName = c.getString(c
.getColumnIndexOrThrow("cName"));
Intent intent = new Intent(getApplication(),
CallRemarks.class);
intent.putExtra("CustomerName", cName);
Toast.makeText(av.getContext(), cName,
Toast.LENGTH_SHORT).show();
Intent CallRemarksScreen = new Intent(
getApplicationContext(), CallRemarks.class);
startActivity(CallRemarksScreen);
}
};
}
});
나는 ListView
및 하단에 여러 개의 버튼이 있습니다. 따라서 기능 (버튼)을 선택하기 전에 첫 번째 항목을 선택해야합니다.
어떤 부분을 끊었습니까? –
항목을 선택할 수 있었지만 (강조 표시 색은 없음) 단추를 클릭하면 선택한 항목이 다른 활동으로 전달됩니다. 내 문제는 버튼을 클릭해도 아무런 변화가 없다는 것입니다. –
지금까지 구현 한 코드를 게시 할 수 있습니까? –