0
もう一度私は困惑しています...次のコードは、SDKと私のGalaxy Nexus(4.0.1を実行中)のAndroid 2.2エミュレータで正常に動作しますが、Xoomでアプリケーションを実行するとNPEを取得します(Android 3.2)NPE on TextView
final TextView resNum = (TextView) findViewById(R.id.resNum);
System.out.println(resNum);
resNum.setOnClickListener(new View.OnClickListener() {
String num = resNum.getText().toString();
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:" + num));
startActivity(callIntent);
}
});
上記はonCreateメソッド(もちろん他のものの中にあります)です。
NPEは、resNum、すなわちprintln()で '読み取り'演算を実行するときに発生します。
ありがとうございました
したがって、findViewByIdはR.id.resNumを見つけることができませんでした。 http://stackoverflow.com/questions/3264610/findviewbyid-returns-null –
あなたが完全な活動を表示できる場合、その方が良い... – ngesh
2.2と4.0.1で動作するのはなぜですか?3.2では失敗しますか? – user1174838