0
我想創建一個活動掃描QR碼和活動來延長IOnclickListenr:我怎麼可以掃描QR碼xamarin安卓
[Activity(Label = "ScanActivity")]
public class ScanActivity : Activity ,IOnClickListener
我定義的OnCreate如下,我有一個掃描按鈕,你可以見:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_scan);
Button scanBtn = FindViewById<Button>(Resource.Id.button_scan);
scanBtn.SetOnClickListener(this);
}
然後我要實現這個功能:
MobileBarcodeScanner scanner;
public void OnClick(View v)
{
//respond to clicks
if (v.Id == Resource.Id.button_scan)
{
//scan
//IntentIntegrator scanIntegrator = new IntentIntegrator(this);
//scanIntegrator.initiateScan();
}
}
public void onActivityResult(int requestCode, Android.App.Result resultCode, Intent intent)
{
// if (scanningResult != null) {
// String scanContent = scanningResult.getContents();
// }
//else{
//Toast toast = Toast.makeText(getApplicationContext(),
// "No scan data received!", Toast.LENGTH_SHORT);
// toast.show();
//}
}
我不知道我怎麼能用c#和Xamarin.Android做到這一點,任何建議都將非常感激,謝謝。