回到我前一天工作的项目 - 当我离开它时,它正在运行,今天错误:(67,93)错误:找不到符号变量drawtab1 。清单可能有问题,试图重建和清理。但是drawtab1没有显示..
TabHost tabHost = getTabHost();
// Tab for login
TabSpec Login = tabHost.newTabSpec("Login");
// setting Title and Icon for the Tab
Login.setIndicator("", getApplicationContext().getResources().getDrawable(R.drawable.drawtab1));
Intent LoginIntent = new Intent(this, Tab1Activity.class);
LoginIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Login.setContent(LoginIntent);
这是 drawtab1
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected -->
<item android:drawable="@drawable/login"
android:state_selected="true" />
<!-- When not selected -->
<item android:drawable="@drawable/login" />
</selector>
这是 Mainfest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tabdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="22"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Tab1Activity"
android:label="@string/title_activity_tab1" >
</activity>
<activity
android:name=".Tab2Activity"
android:label="@string/title_activity_tab2" >
</activity>
<activity
android:name=".Tab3Activity"
android:label="@string/title_activity_tab3" >
</activity>
</application>
</manifest>
非常感谢任何帮助。
答案 0 :(得分:1)
这里可能有一些案例
1. make sure there is not import android.R import statement.
2. no error in typos in xml file.
3. use only a-z and 0-9 for resource name it must not contain any capital letters or special symbol. Then clean and sync your project.