Erroneous Caused by: java.lang.ClassCastException: SettingsActivity cannot be cast to android.app.Activity
-
He's losing an app when he's trying to stitch. part MainActivity.java:
public boolean onCreateOptionsMenu(Menu menu) { MenuItem mi = menu.add(0, 1, 0, R.string.pref); mi.setIntent(new Intent(this, SettingsActivity.class)); return super.onCreateOptionsMenu(menu); }
SettingsActivity.java:
package ru.devgor.gorlovka;
import android.os.Bundle;
import android.preference.PreferenceFragment;public class SettingsActivity extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) throws ClassCastException {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref);
}
}
pref.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:key="chb"
android:title="Wifi при выходе" android:summaryOn="При выходе wifi будет выключаться" android:summaryOff="При выходе wifi не будет выключаться">
</CheckBoxPreference>
<CheckBoxPreference android:key="chb1" android:title="Wifi при входе" android:summaryOn="При входе wifi будет включаться" android:summaryOff="При входе wifi не будет включаться"/>
<CheckBoxPreference android:key="chb2" android:title="Загрузка картинок" android:summaryOn="При быстром интернете" android:summaryOff="При мобильном интернете"/><PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:title="Первая кнопка">
<EditTextPreference android:key="btn11" android:dialogTitle="Название" android:dialogMessage="Введите название первой кнопки"/>
<EditTextPreference android:key="btn12" android:dialogTitle="Ссылка" android:dialogMessage="Введите ссылку, на которую следует перейти"/>
</PreferenceScreen>
</PreferenceScreen>
-
As you've noticed, you're trying to launch an activism, but your class, which you're sending to the designer.
Intent
- Yes.PreferenceFragment
♪That's what he tells you.
ClassCastException
♪