我是android.I的新手我正在開發一個應用程序,因爲我有兩個按鈕在1 screen.I必須執行不同的操作基於特定的按鈕clicked.I必須根據哪個按鈕進行區分被點擊。在android中的按鈕差異
public void showSelectedNumber(int type, String number)
{
--->Here i have to set two conditions:
1.This for call
try
{
// Intent callIntent = new Intent(Intent.ACTION_CALL); //Call options
////// Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
////// while (cursor.moveToNext()) {
////// String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
////// }
// callIntent.setData(Uri.parse("tel:"+number));
// startActivity(callIntent);
This is for SMS:
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("sms:" //sms options
+ number)));
}
catch (ActivityNotFoundException e)
{
Log.e("helloandroid dialing example", "Call failed", e);
}
Toast.makeText(this, type + ": " + number, Toast.LENGTH_LONG).show();
}
}
你要我做什麼?請問可以更具描述性? – vnshetty 2012-04-27 06:05:17
嗨vnshetty我的問題是在上面的代碼「ShowSelectedNumber」中有2行這是爲了調用,這是爲了短信。我必須區分這兩部分。但我只有2個按鈕沒有別的別的。我可以通過點擊按鈕來區分這一點。 – subburaj 2012-04-27 06:07:48
你可以爲通話和短信編寫不同的方法嗎?這是什麼問題,並通過引用下面的任何答案來實現點擊監聽器。 – vnshetty 2012-04-27 06:14:00