requestFocus failed

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

requestFocus failed

Postby The_One_Neo » Tue Feb 03, 2009 10:29 am

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
ScrollView sv = new ScrollView(this);
ViewGroup.LayoutParams svLp = new ScrollView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);

LinearLayout ll = new LinearLayout(this);
ll.setLayoutParams(svLp);
sv.addView(ll);

isv = new ChapterListView(this, extras);
isv.setOnClickListener(mList);

boolean b = isv.isFocusableInTouchMode();
b = isv.isFocusable();
isv.requestFocus();
b = isv.isFocused();


int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
12 * screenHeight); // 2x screen height to ensure scrolling
isv.setLayoutParams(llLp);
ll.addView(isv);
setContentView(sv);
isv.requestFocus();
}

i created a new view ChapterListView in the ScrollView

i used requestFocus() for the chaterview , but that can't get the focus , isFocused() is false.

i tested the chapterview isFocusableInTouchMode() is false.

In the view press the key and into focuschanged function , the view get the focus
protected void onFocusChanged(boolean focused, int direction,
Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}

why i can't set default focus for the chapterview?
The_One_Neo
Developer
Developer
 
Posts: 28
Joined: Wed May 07, 2008 9:34 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests