0

基本的に、Eclipse と Android 開発ツールが提供するデフォルトの新しいアクティビティ UI を、スクロール可能なタブとスワイプで構築しました。

Fragment基づいています。

フラグメント内のビューを膨張させようとしています。このビューにボタン クリック リスナーをアタッチすると、AsyncTask が開始され、そのonPostExecuteメソッドに進行状況ダイアログが表示されます。

ここにいくつかのコードがあります:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

            View rootView = inflater.inflate(R.layout.my_view, container, false);

            Button bProcess= (Button) rootView.findViewById(R.id.bJustParked);
            bProcess.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    new JustParkedGetLocation().execute();
                }

            });

            // Modify views in fragment below

            return rootView;
        }

明らかに、JustParkedGetLocationAsyncTask を拡張し、onCreateView上記のメソッドを保持するクラスのサブクラスです。ただし、たとえば、でダイアログを作成する場合JustParkedGetLocation->onPreExecute():

@Override
protected void onPreExecute() {
    ProgressDialog progress = new ProgressDialog(this);
    progress.setIndeterminate(true);
    progress.setTitle("Getting location");
    progress.show();
    super.onPreExecute();
}

...メソッドを保持するクラスはデフォルトで静的 (を拡張するクラス) であるため、コンストラクターのパラメーターがProgressDialog正しくありません。次のエラーが発生します。onCreateViewFragment

The constructor ProgressDialog(MainActivity.ExtendedFragment.JustParkedGetLocation) is undefined
4

1 に答える 1