我进行了编辑测试focusable="false"
。
如何使用EditText移动到下一个XML表单?
有可能吗?
如何将onclicklistener用于edittext?
android:id="@+id/editText2"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:hint="Agenda Template"
android:ems="10"
android:focusable="false" />
答案 0 :(得分:2)
设置您的edittext android:clickable="true"
并添加点击监听器,如下所示:
<EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/refresh" android:layout_centerHorizontal="true" android:ems="10" android:clickable="true" android:focusable="false"> EditText m_et=(EditText)findViewById(R.id.editText1); m_et.setOnClickListener(new OnClickListener() { @Override public void onClick(View p_v) { // TODO Auto-generated method stub System.out.println("EditeText Cliecket ==============="); } });
答案 1 :(得分:0)
public class MainActivity extends Activity {
EditText ev;
Button b;
TextView tv;
static String str;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ev=(EditText)findViewById(R.id.editText1);
b=(Button)findViewById(R.id.button1);
tv=(TextView)findViewById(R.id.textView1);
ev.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("edittext button");
}
});
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
str=ev.getText().toString();
tv.setText(str);
//getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(ev.getWindowToken(), 0);
// TODO Auto-generated method stub
}
});
}
}
试试此代码
答案 2 :(得分:0)
在editText上使用OnTouchListener而不是onClickListener。 这可能有用。