I am developing Android Application having ContactUs Page having Phone Number. I had given the Phone number in xml file as below:
<TextView
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="1-869-270-9099"
android:textSize="11sp"
android:textColor="#104082"
android:textStyle="normal"
android:layout_width="wrap_content"
android:id="@+id/textView4"
android:layout_x="72dp"
android:layout_y="160dp"/>
I had created the AlertDialog and when the phone number is clicked the alert dialog will be shown programatically as below:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case (R.id.textView4):
Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Do you want to Call?");
builder.setCancelable(false);
builder.setPositiveButton("Call", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Do Calling a Number
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
return super.onCreateDialog(id);
}
public void onClick(View v) {
switch(v.getId()){
case (R.id.textView4):
showDialog(R.id.textView4);
break;
}
}
Here my issue is to implement the “Calling a Phone Number” Function in the onClick “PositiveButton” method. Please help me how to get a DialPad with the number present in the xml file with the SampleCode/Links.
Maybe something like: