I have displayed a gridview whose items are a textview and edittext.Now ,how to achieve function that I click the gridview item and the edittext get the focus?
gridview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
how to override this function? I try that before:
((EditText)gridview.getChildAt(position).findViewById(R.id.grid_edittext)).requestFocus();
and also:
((ViewGroup)gridview.getChildAt(position)).getChildAt(1).requestFocus();
There adds a System.out.printlen("hello"); in onitemclick function,but it doesn't show up in logcat.
Is there any samples??
When Using gridView, TextView and EditText should not have the flag
unless you want a foreign focus behavior, you can use instead
don't ask me why! it's kind of android OS bug, Hope this will help,
Get
EditText
fromAdapterView
and setrequestFocus()
as below. This may be work.EDIT: Set
focusable
andfocusableInTouchMode
tofalse
forEditText
as below: