简体   繁体   中英

Copy Button not showing in AlertDialog

I am showing a dialog with existing name pre-filled in the TextView .

I want to show "Copy Text" option which is not being shown by default when text portion in selected. Please suggest. Right not it is only showing Text Selection without Copy button.

following is my existing code.

final TextViewinput = new TextView(this); 
            input.setTextIsSelectable(true);

            new AlertDialog.Builder(context)
            .setTitle("Edit File Name")
            .setView(input).show();

For Pre-HoneyComb use :-

import android.text.ClipboardManager;

textView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        ClipboardManager cm = (ClipboardManager)context.getSystemService(Context.CLIPBOARD_SERVICE);
        cm.setText(textView.getText());
        Toast.makeText(context, "Copied to clipboard", Toast.LENGTH_SHORT).show();
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM