ví dụ sử dụng roboguice.
Mã này nhận được ClassCastException.java.lang.ClassCastException: android.app.Application không thể được cast thành roboguice.application.RoboApplication
public class MainActivity extends RoboActivity{
@InjectView(R.id.text)
TextView name;
@InjectView(R.id.imageView1)
ImageView imageView;
Drawable icon;
@InjectResource(R.string.app_name)
String myName;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
tất cả các tệp jar đã được bao gồm.
Tệp manifest.xml của tôi ở đây ..
tìm nội dung này tại đây.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.roboguice"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.roboguice.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
không có thay đổi trong tệp manifest.xml. nếu được yêu cầu rồi nói.
xin vui lòng gửi manifest.xml của bạn –
@BirajZalavadia Tôi đã thêm manifest.xml –
@BirajZalavadia Ứng dụng đã hoạt động, cảm ơn. –