0

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.

enter image description here

But,how to get the Find and Share options like below screen.

enter image description here

Mr. N.V.Rao
  • 1,082
  • 13
  • 27

3 Answers3

0

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:

http://developer.android.com/reference/android/view/View.html#setOnLongClickListener(android.view.View.OnLongClickListener)

thomasg
  • 571
  • 4
  • 17
  • Is it possible to select the user wanted area @Thomas – Mr. N.V.Rao Feb 26 '14 at 11:43
  • If `textIsSelectable` is set to `true`, user will have the ability to select their area and copy it but you won't be able to provide the share feature. If you use `OnLongClickListener()`, you can display your own popup but the user won't be able to select a specific area. That's a compromise. You can probably implement your own TextView behavior to provide both, but it's not gonna be easy. – thomasg Feb 26 '14 at 11:54
  • how to select the specific textarea @Thomas – Mr. N.V.Rao Feb 26 '14 at 12:02
0

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>
Shihab Uddin
  • 6,699
  • 2
  • 59
  • 74
0

After lot of research i found the answer for my question. Answer is Android- How can I show text selection on textview?

Community
  • 1
  • 1
Mr. N.V.Rao
  • 1,082
  • 13
  • 27