English 中文(简体)
B. 如何了解目前侧重哪些观点
原标题:how to know which view has current focus

I am putting focus on a view but when I change orientation the focus is lost from that view . does onConfigurationChanged() handles focus? or i need to explicitly set it and if yes then how can I set focus ? I need to keep track of current focusing view .how to do that?

最佳回答

• 在你的活动中,克服依赖国家和居住国的方法。 那么,你就能够追踪任何观点的焦点,把观点的识别资料放在光辉的国家方法中,将其保留到联邦上。 然后,在“RestoreInstanceState”方法中,你只是 gr住了该身份证,并发现了该身份证。 你们甚至不需要去做。 那么,你只是要求把这一观点作为重点。 它希望:

@Override
protected void onSaveInstanceState(Bundle outState) {       
    int viewId = this.getCurrentFocus().getId();
    outState.putInt("hasFocus", viewId);

    super.onSaveInstanceState(outState);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {      
    super.onRestoreInstanceState(savedInstanceState);

    int viewId = savedInstanceState.getInt("hasFocus");
    View view = findViewById(viewId);
    view.requestFocus();        
}
问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签