如何在 setOnItemLongClickListener 中实现联系人呼叫按钮?
How to Implement Contact Call Button in setOnItemLongClickListener?
I want to implement a Call A Number Button in My App, How Can I Do that?
mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long l) {
//Alert dialog to display options of update and delete
final CharSequence [] items = {"Update","Delete","Call"};
AlertDialog.Builder dialog = new AlertDialog.Builder(RecordListActivity.this);
dialog.setTitle("Choose an Action");
dialog.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if(i == 0){
//update
Cursor c = MainActivity.mSQLiteHelper.getData("SELECT id FROM RECORD");
ArrayList<Integer> arrID = new ArrayList<Integer>();
while(c.moveToNext() ){
arrID.add(c.getInt(0));
}
//Show update Dialog
showDialogUpdate(RecordListActivity.this,arrID.get(position));
}
if(i==1){
//delete
Cursor c = MainActivity.mSQLiteHelper.getData("SELECT id FROM RECORD");
ArrayList<Integer> arrID = new ArrayList<Integer>();
while(c.moveToNext()){
arrID.add(c.getInt(0));
}
showDialogDelete(arrID.get(position));
}
if(i==3){
//Call Method, I don't know how to do that, cause I already use a Model, I don't know how to do that.
}
}
});
dialog.show();
return true;
}
});
I am new to Android, How to make a contact call in setOnItemLongClickListener().from the top I added my setOnItemLongClickListener method to how can I implement with this.
如果我没理解错的话,那你想知道怎么拨打电话吗?
此代码适用于您的项目,它将打开一个通话应用程序,号码为 phone:
TextView tvPhone = view.findViewById(R.id.textphone);
String phone = tvPhone.getText().toString();
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + phone));
view.getContext().startActivity(intent);
I want to implement a Call A Number Button in My App, How Can I Do that?
mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long l) {
//Alert dialog to display options of update and delete
final CharSequence [] items = {"Update","Delete","Call"};
AlertDialog.Builder dialog = new AlertDialog.Builder(RecordListActivity.this);
dialog.setTitle("Choose an Action");
dialog.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if(i == 0){
//update
Cursor c = MainActivity.mSQLiteHelper.getData("SELECT id FROM RECORD");
ArrayList<Integer> arrID = new ArrayList<Integer>();
while(c.moveToNext() ){
arrID.add(c.getInt(0));
}
//Show update Dialog
showDialogUpdate(RecordListActivity.this,arrID.get(position));
}
if(i==1){
//delete
Cursor c = MainActivity.mSQLiteHelper.getData("SELECT id FROM RECORD");
ArrayList<Integer> arrID = new ArrayList<Integer>();
while(c.moveToNext()){
arrID.add(c.getInt(0));
}
showDialogDelete(arrID.get(position));
}
if(i==3){
//Call Method, I don't know how to do that, cause I already use a Model, I don't know how to do that.
}
}
});
dialog.show();
return true;
}
});
I am new to Android, How to make a contact call in setOnItemLongClickListener().from the top I added my setOnItemLongClickListener method to how can I implement with this.
如果我没理解错的话,那你想知道怎么拨打电话吗?
此代码适用于您的项目,它将打开一个通话应用程序,号码为 phone:
TextView tvPhone = view.findViewById(R.id.textphone);
String phone = tvPhone.getText().toString();
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + phone));
view.getContext().startActivity(intent);