android - how to make a text view selectable? -


i use adapter load list view content provider. each item in list uses below layout.

i looking way make text view selectable. have tried using android:textisselectable="true" , android:selectallonfocus="true", these make text within text view selectable. want make whole text view selectable, instead of text within it, can add functions delete , share it. there way achieve that?

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content">      <linearlayout         android:id ="@+id/wrapper"         android:layout_width="match_parent"         android:layout_height="wrap_content">          <textview             android:id="@+id/txt_chat"             android:layout_height="wrap_content"             android:layout_width="wrap_content"             android:layout_gravity="center"              android:textisselectable="true"             android:selectallonfocus="true"             />          </linearlayout> </linearlayout> 

edit : suggested @kgandroid in comments,i have used context menu partially achieve desired functionality below code. removed android:textisselectable" , android:selectallonfocus attributes item layout file.

oncreate(){     ..     ...     lv_chatmessages = (listview) findviewbyid(r.id.listview_chat);     registerforcontextmenu(lv_chatmessages);     ... }   @override     public void oncreatecontextmenu(contextmenu menu, view v, contextmenu.contextmenuinfo menuinfo){         if(v.getid() == r.id.listview_chat){             listview lv = (listview) v;             adapterview.adaptercontextmenuinfo acmi = (adapterview.adaptercontextmenuinfo) menuinfo;             menu.add("first option");             menu.add("second option");         }      } 

but still not able 2 things :

  1. select multiple items in list view before context menu appears.
  2. have context menu appear icons on top of screen, similar happens default when text selected.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -