I am using the following tag in textview to copy the text.
android:textIsSelectable="true"
And I am getting the following Screen when i am selecting the textview.
But,how to get the Find and Share options like below screen.
I am using the following tag in textview to copy the text.
android:textIsSelectable="true"
And I am getting the following Screen when i am selecting the textview.
But,how to get the Find and Share options like below screen.
You have to implement it by yourself:
When the tap/long press on the text, display your popup.
I would probably do it, using OnLongClickListener()
on the text:
you have to create a custom dialog as your own.
All procedure is below.
Crate a Custom Dialog Class:
public class CustomizedDialog extends Dialog implements
android.view.View.OnClickListener {
Context context;
public CustomizedDialog(Context context) {
super(context);
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Button aButton = (Button) findViewById(R.id.btnDialogCancel);
}
@Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
// TextView objMesaageView = new TextView(context);
}
@Override
public void setTitle(CharSequence title) {
super.setTitle(title);
}
@Override
public void onClick(View v) {
}
} Then call this class from your activity.
CustomizedDialog dialog;
// open a dialog
private void showDialog() {
dialog = new CustomizedDialog(getActivity());
dialog.setContentView(R.layout.dialog_add_number_type);
dialog.setTitle("Add Black List Number");
TextView textViewAddNumber=(TextView)dialog.findViewById(R.id.layoutCallLog);
textViewAddNumber.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// write your code here.
}
});
dialog.show();
}
My layout xml like:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:background="#9acd32" >
<RelativeLayout
android:id="@+id/layoutAddBlockNumbers"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/layoutCallLog"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal" >
<Button
android:id="@+id/btnTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="12dp"
android:text="test" />
<TextView
android:id="@+id/textViewAddNumber"
style="@style/heading_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="14dp"
android:text="@string/add_from_call_log" />
</LinearLayout>
</RelativeLayout>
After lot of research i found the answer for my question. Answer is Android- How can I show text selection on textview?