0

I know there is another question just like this one but still haven't answer working for me.

I have a TextView in my fragment with informations inside.It's a long textview with a scrolling bar. I want to copy paste some information but can't select and copy.

There is my TextView :

<TextView
            android:id="@+id/tv_observ_client"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="40dp"
            android:textIsSelectable="true"
            android:layout_marginEnd="5dp"
            android:textColor="@android:color/black"
            android:scrollbars="vertical"
            android:enabled="true"
            android:focusable="true"
            android:longClickable="true"
            android:text="Info pratiques " />

I'm able to copy all the TextView's but I only want some information.

Thank's


EDIT

This is all the layout, it may help :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Fragments_info_client.Coordonne_client"
    android:orientation="vertical">

    <!-- TODO: Update blank fragment layout -->
    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
        android:orientation="horizontal">

    <TextView
        android:id="@+id/tv_nom_cli"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:textColor="@android:color/black"
        android:text="Nom client"
        android:textStyle="bold">


    </TextView>
        <TextView
            android:id="@+id/tv_codeP_cli"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:layout_marginTop="10dp"
            android:textColor="@android:color/black"
            android:text="Code postal client"
            android:layout_marginStart="10dp">
        </TextView>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginTop="5dp">

        <TextView
            android:id="@+id/tv_adresse_cli"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="10dp"
            android:text="Adresse Client"
            android:textStyle="bold"
            android:textColor="@android:color/black"
             />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="5dp">

        <TextView
            android:id="@+id/tv_ville_cli"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:textColor="@android:color/black"
            android:layout_marginLeft="10dp"
            android:text="Ville Client"
            android:textStyle="bold"></TextView>

        <TextView
            android:id="@+id/tv_tel_cli"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="10dp"
            android:text="Tel Client"
            android:textStyle="bold"
            android:textColor="@android:color/black"
             ></TextView>
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imgBtn_tel_client"
            android:src="@drawable/call_answer"></ImageButton>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="5dp">


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/tv_nb_hab"
            android:text="Nombre habitants : "
            android:layout_marginTop="10dp"
            android:textStyle="bold"
            android:textColor="@android:color/black"
            android:layout_marginLeft="10dp">

        </TextView>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/tv_observ_client"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="40dp"
            android:textIsSelectable="true"
            android:layout_marginEnd="5dp"
            android:textColor="@android:color/black"
            android:scrollbars="vertical"
            android:enabled="true"
            android:focusable="true"
            android:longClickable="true"
            android:text="Info pratiques " />
    </LinearLayout>
</LinearLayout>

This textview is in a fragment, this fragment is handle by a viewpager adapter with differents tabs, I wonder if this case can't give the focusable(and selectable) to the textview because of the swipe action. Hope it's will help

Spiker
  • 522
  • 4
  • 21
NeoKerd
  • 189
  • 3
  • 13
  • 1
    this will work for you https://stackoverflow.com/a/40837286/4390987 – ॐ Rakesh Kumar Jan 21 '20 at 13:21
  • @RakeshKumar Hi, i am trying but i just can't select my text – NeoKerd Jan 21 '20 at 13:27
  • in my code i just set text is selectable because i think this it's a problem about xml, i just want to select part of my text view ( like we do in browser when we want to copy) and next copy in the phone's keyboard. this is the java code : tv_observation=view.findViewById(R.id.tv_observ_client); tv_observation.setMovementMethod(new ScrollingMovementMethod()); tv_observation.setTextIsSelectable(true); – NeoKerd Jan 21 '20 at 13:34
  • I am able to select part of the text through your xml layout. There is no problem for me. – seyfullah.bilgin Jan 21 '20 at 14:26
  • @seyfullah.bilgin So where can i have a problem ? – NeoKerd Jan 21 '20 at 14:27
  • I have edit with my complete layout, it may help – NeoKerd Jan 21 '20 at 14:41

2 Answers2

2

Try this:

android:textIsSelectable.

i.e., android:textIsSelectable="true"

Rawal A
  • 31
  • 5
0

Ok so, I found the problem by myself, I wasn't able to select because i have a

setMovementMethod(new ScrollingMovementMethod());

I tried to delete this one and it's work. Thx for ur help

NeoKerd
  • 189
  • 3
  • 13