Android Long Press on Edit Text behavior

前端 未结 3 660
攒了一身酷
攒了一身酷 2020-12-05 21:44

Is it possible to add something to the list of items that shows up when a user long presses on any Edit Text? (Cut, copy paste, select text, select all, input method) I want

3条回答
  •  隐瞒了意图╮
    2020-12-05 21:58

    Yes it is possible to add something to the list of items on LongClick of EditText.

    To put you in right direction I am posting some code snippets.

    In main.xml do something like

    
    
    
    
    
    
    

    After that in your main Activity, do something like

    public class edit extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        EditText text = (EditText)this.findViewById(R.id.textt);
        text.setOnLongClickListener(new OnLongClickListener() {
    
            @Override
            public boolean onLongClick(View v) {
    
                //ADD HERE ABOUT CUT COPY PASTE  
                // TODO Auto-generated method stub
                return false;
            }
        });
    }
    }
    

    Hope it helps

提交回复
热议问题