2

私は最初のアンドロイド学習チュートリアルを行っていますが、タイトルが説明するこのエラーで立ち往生しています..これは私がEclipseでやろうとしているアプリです、Java、ここに私のコードがあります..(コードはプロジェクトによって自動生成されます)

package com.HelloWorkLight;
import android.R;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;

import org.apache.cordova.CordovaActivity;``

import com.worklight.androidgap.api.WL;
import com.worklight.androidgap.api.WLInitWebFrameworkResult;
import com.worklight.androidgap.api.WLInitWebFrameworkListener;

public class HelloWorkLight extends CordovaActivity implements      WLInitWebFrameworkListener {

@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    WL.createInstance(this);

    WL.getInstance().showSplashScreen(this);

    WL.getInstance().initializeWebFramework(getApplicationContext(), this);

}

/**
 * The IBM MobileFirst Platform calls this method after its initialization is complete and web resources are ready to be used.
 */
public void onInitWebFrameworkComplete(WLInitWebFrameworkResult result){
    if (result.getStatusCode() == WLInitWebFrameworkResult.SUCCESS) {
        super.loadUrl(WL.getInstance().getMainHtmlFilePath());
    } else {
        handleWebFrameworkInitFailure(result);
    }
}

private void handleWebFrameworkInitFailure(WLInitWebFrameworkResult result){
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setNegativeButton(R.string.close, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which){
            finish();
        }
    });

    alertDialogBuilder.setTitle(R.string.error);
    alertDialogBuilder.setMessage(result.getMessage());
    alertDialogBuilder.setCancelable(false).create().show();
}
}

前もって感謝します :)

4

1 に答える 1

1

Check the file values/strings.xml to see if there is a string by that name. Otherwise, you can add it:

<string name="close">Close</string>

You may also want to try Cancel instead of Close, as this is general practice.

If that wasn't your problem, usually the problem in these cases is with import android.R. Try removing it and doing a clean build of your project.

Note: When you're using stock strings, make sure you use their fully-qualified name to avoid potential problems: android.R.string.no, for example.

If the class files aren't in the root package, you import R like this: my.packagename.R

于 2015-09-07T18:38:15.290 に答える