-1
請告訴我我的代碼有什麼問題? .setPositiveButton方法拋出了紅線錯誤。它無法讀取smsText。我試圖宣佈smsText公開,但問題是一樣的。無法解決方法錯誤
public class PrepaidSMSBase extends Activity {
private String smsNumber = "";
private String smsPackageName;
private String smsPrice;
private String smsTitle;
private String smsText;
public PrepaidSMSBase(){}
public void setSmsPackageInformation(String smsTitle, String smsPackageName, String smsPrice, String smsNumber, String smsText)
{
this.smsTitle = smsTitle;
this.smsPackageName = smsPackageName;
this.smsPrice = smsPrice;
this.smsNumber = smsNumber;
this.smsText = smsText;
}
public void activeSMSPackage()
{
try
{
AlertDialog.Builder builder = new AlertDialog.Builder(PrepaidSMSBase.this);
builder.setTitle(smsTitle);
builder.setMessage("Are you sure you want to active" + PrepaidSMSBase.this.smsPackageName + "in RS: " +
PrepaidSMSBase.this.smsPrice);
builder.setPositiveButton(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Uri uri = Uri.parse("smsto:" + smsNumber);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", smsText);
startActivity(intent);
Toast.makeText(getApplicationContext(), "Please click send button to activate desire Package", Toast.LENGTH_LONG).show();
}
});
}catch (ActivityNotFoundException e){
e.printStackTrace();
}
}
}
進口所需的所有類。 OnClickListener()應該是父級DialogInterface。還導入DialogInterface – EagleEye
問題仍然exixt –
什麼是「reline」的錯誤描述? – EagleEye