我在textview中显示文本,看起来太长,无法放入一个屏幕.我需要让我的TextView可滚动.我怎样才能做到这一点?
这是代码:
final TextView tv = new TextView(this);
tv.setBackgroundResource(R.drawable.splash);
tv.setTypeface(face);
tv.setTextSize(18);
tv.setTextColor(R.color.BROWN);
tv.setGravity(Gravity.CENTER_VERTICAL| Gravity.CENTER_HORIZONTAL);
tv.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent e) {
Random r = new Random();
int i = r.nextInt(101);
if (e.getAction() == e.ACTION_DOWN) {
tv.setText(tips[i]);
tv.setBackgroundResource(R.drawable.inner);
}
return true;
}
});
setContentView(tv);
Run Code Online (Sandbox Code Playgroud) "TextView不支持文本选择.操作模式已取消."
当我尝试在Android中的PopupWindow中的EditText中调出上下文菜单时,我收到此错误.选择标记也不起作用.
这个问题已被多次询问,但一直未得到答复:
如何在PopupWindow中为EditText启用选择标记?
PopupWindow不会在EditText上长按触发系统上下文对话框
我只是处理同一问题的另一个人.有任何想法吗?
我有RecyclerView.位置的元素是0是标题EditText,然后所有其他元素都是图像.长按EditText它会给出选项粘贴.这很好用.但是,当我将回收器视图滚动到底部并再次到达顶部并长按时,它将不会显示粘贴选项并给出错误.在滚动到底部并再次到达顶部传递呼叫onBindViewHolder.
TextView:TextView不支持文本选择.选择取消.
public class Someclass extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements View.OnClickListener {
private static final int TYPE_EDIT = 0;
private static final int TYPE_IMAGE = 1;
List<String> msomelist = new ArrayList<String>();
public void someMethod(List<String> somelist) {
msomelist.clear();
msomelist.addAll(somelist);
notifyDataSetChanged();
}
public Someclass(Activity activity, List<String> somelist) {
this.activity = activity;
this.msomelist.clear();
this.msomelist.addAll(somelist);
mContext = activity;
}
@Override
public int getItemViewType(int position) {
if (position == 0)
return TYPE_EDIT;
return TYPE_IMAGE;
}
@Override …Run Code Online (Sandbox Code Playgroud)