我的应用程序中显示的默认选项卡是选项卡0.我想在单击Preference uso时,将currentTab更改为1,以及下次应用程序打开时,将显示选项卡1而不是选项卡0
这是Preferences.java内容:
package com.fbisoft.uowt;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceClickListener;
import android.widget.TabHost;
import android.widget.Toast;
public class Preferences extends PreferenceActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
getPreferenceManager().findPreference("uso").setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
TabHost.setCurrentTab(1);
return true;
}
});
}
}
TabHost.setCurrentTab(1);
给了我一个错误:
Cannot make a static reference to the non-static method setCurrentTab(int)
from the type TabHost
答案 0 :(得分:1)
您需要让自己的活动TabHost
关注偏好更改,然后在此处更改您的标签。您无法告诉TabHost
班级更改标签。