-4

So i want to enable copy and paste option in my static android app and I tried every single way to enabling copy paste option but every time add code, it gives me errors and warning in my whole code. can anyone please help. can anyone tell me or edit these code for enabling copy and paste option in my android app

Activity.xml file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sample.youtuber.health.SecondActivity">


   <ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="19dp"
    android:layout_marginRight="19dp"
    android:layout_marginStart="19dp"
    android:layout_marginTop="18dp"
    >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">


<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="200dp"
    tools:ignore="ContentDescription"
    android:src="@drawable/browse"
    android:scaleType="fitXY"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:id="@+id/textview"
    android:text="@string/How_To_Browse_Deep_Web"
    android:textAlignment="center"
    android:layout_gravity="center"
    />
    </LinearLayout>
</ScrollView>


</RelativeLayout>

Activity.java file

package com.sample.youtuber.health;

import android.annotation.TargetApi;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;


public class SecondActivity extends ActionBarActivity {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    TextView text = (TextView) findViewById(R.id.textview);
    text.setMovementMethod(LinkMovementMethod.getInstance());

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_second, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
    }
}
Sushin Pv
  • 1,826
  • 3
  • 22
  • 36
Anand
  • 13
  • 2

2 Answers2

3

Add this Line to your Textview

android:textIsSelectable="true"
Girish
  • 100
  • 7
0

Add this line to textview :

 android:longClickable="true"
 android:textIsSelectable="true"

In your Java class write this line to set it programmatically.

myTextView.setTextIsSelectable(true);
Vidhi Dave
  • 5,614
  • 2
  • 33
  • 55