新しい Android プロジェクトで問題が発生しました。インテントの開始で共有設定を使用できません。プロジェクトを実行しているときに、強制的に終了し、log-cat にヌル ポインター例外が表示されます。誰でもこの問題を解決するために何か提案できますか? そして、ここに私のクラスがあります
public class NextActivity extends Activity {
String a,b;
Context cntxt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nextlayout);
TextView et3 = (TextView)findViewById(R.id.textView3);
SharedPreferences prefs = cntxt.getSharedPreferences("myprefs", 0);
a = prefs.getString("KEY_FIRST","");
et3.setText(a);
Button btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
Intent t = new Intent(cntxt,Kl_Activity.class);
startActivity(t);
}
// and get whatever type user account id is
});
}
}