我在textview中使用下面的标记来复制文本。
android:textIsSelectable="true"当我选择文本视图时,我得到了下面的屏幕。

但是,如何获得像下面这样的查找和共享选项。

发布于 2014-02-28 06:05:06
经过大量研究,我找到了我的问题的答案。答案是Android- How can I show text selection on textview?
发布于 2014-02-26 11:41:41
你必须自己实现它:
当点击/长按文本时,显示你的弹出窗口。
我可能会这样做,在文本上使用OnLongClickListener():
http://developer.android.com/reference/android/view/View.html#setOnLongClickListener(android.view.View.OnLongClickListener)
发布于 2014-02-27 07:03:09
您必须创建一个自定义对话框作为您自己的。
所有程序如下。
装入自定义对话框类:
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) {
}}然后从您的活动中调用该类。
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();
}我的布局xml如下:
<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>https://stackoverflow.com/questions/22040192
复制相似问题