0
我想顯示來自mySpinner的字符串編號只在我的Toast中,但我找不到做那件事。歡迎任何幫助!並不重要android java獲取微調器選定的字符串值
spinnerClickListener();
}
ONCLICK方法的ImageButton顯示舉杯所選擇的聯繫人的電話號碼
if(cursor.moveToFirst())
{
do
{
String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
if(Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0)
{
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",new String[]{ id }, null);
while (pCur.moveToNext())
{
String name = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String number = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
list.add(name + "\n" + number);
break;
}
pCur.close();
}
} while (cursor.moveToNext()) ;
}
適配器東西。
public void spinnerClickListener(){
//spinner item button onclick listener
callBTN = (ImageButton)findViewById(R.id.call);
mySpinner = (Spinner)findViewById(R.id.contacts);
callBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Selected number :" + "\n" + mySpinner.getSelectedItem(), Toast.LENGTH_LONG).show();
}
});
}
在此先感謝!
? –
spinnerClickListener();在onCreate – svenvdz
顯示代碼太 –