我正在构建一个 nfc 读取标签应用程序。但我找不到设置布局。
setContentView(R.layout.read)中的问题
; 和
txtRead = (TextView) findViewById(R.id.txt_read);
这是我的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.read);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.read);
// nfcAdapter = NfcAdapter.getDefaultAdapter(null);
// detectedTag =getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
txtRead = (TextView) findViewById(R.id.txt_read);
pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0,
new Intent(this,getClass()).
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
IntentFilter filter2 = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
// readTagFilters = new IntentFilter[]{tagDetected,filter2};
Toast.makeText(this, "no Exception caught in on create", Toast.LENGTH_LONG).show();
}
catch(Exception e) { Toast.makeText(this, "Exception caught in on create", Toast.LENGTH_LONG).show(); }
}