1

私はよくグーグルで検索し、このウェブサイトの質問の多くを調べましたが、問題の解決策が見つかりません.

以下のような進行状況ダイアログを作成したいのですが、その方法がわかりません..カスタムの進行状況ダイアログを作成しようとしましたが..それでは内側のスピナーの外観しか変更できません..そのレイアウトを変更したい場合...どうすればそれを達成できますか...????

今まで私は次のことを試しました...

public class nextclass extends Activity {

    Thread t;
    ProgressBar dia;

    private ProgressDialog progressDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        MainActivity.progressDialog.dismiss();
        setContentView(R.layout.nextclassview);
    //  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

        ((Button) findViewById(R.id.button1))
                .setOnClickListener(new OnClickListener() {

                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        // progressDialog = findViewById(R.id.progressBar1);

                        new AuthenticateUserTask().execute();
                    }
                });
    }

    private class AuthenticateUserTask extends AsyncTask<Void, Void, String> {

        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub
            super.onPreExecute();

            progressDialog = ProgressDialog.show(
                    nextclass.this, "","Sucessful", true);
/*            progressDialog.setIndeterminate(true);

            progressDialog.setIndeterminateDrawable(getResources()
                    .getDrawable(R.layout.customspinner));
*/


            progressDialog = ProgressDialog.show(nextclass.this, "",
                    "Processing....", true);
            progressDialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

        }

        protected void onPostExecute(String s) {
            if (progressDialog.isShowing())
                progressDialog.dismiss();

            Intent my = new Intent(getApplicationContext(), CountTime.class);
            startActivity(my);

        }

        @Override
        protected String doInBackground(Void... params) {
            // TODO Auto-generated method stub
            try {
                Thread.sleep(2000);![custom spinner][2]
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }
    }
}

ここに画像の説明を入力

4

2 に答える 2

1

カスタム ダイアログの作成方法の詳細については、このリンクを参照してください。

WindowManager.LayoutParams WMLP = dialog.getWindow().getAttributes();


     WMLP.x = 100;   //x position
     WMLP.y = 100;   //y position

     dialog.getWindow().setAttributes(WMLP);

Edit2: コードを使用してダイアログアクティビティを作成するサンプルを以下に示します

public class DialogActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(" ");
        alertDialog.setMessage("");
        alertDialog.setIcon(R.drawable.icon);
        alertDialog.setButton("Accept", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {                
            }
        });
        alertDialog.setButton2("Deny", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        alertDialog.show();
    }
}

そしてAndroidマニフェストファイルで

android:theme="@android:style/Theme.Translucent.NoTitleBar"

また

AlertDialog.Builder builder = new AlertDialog.Builder(
                    new ContextThemeWrapper(context, R.style.popup_theme));

値フォルダー内:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="back_color">#ffffffff</color>
<style name="popup_theme" parent="@android:style/Theme.Translucent.NoTitleBar">
    <item name="android:windowBackground">@color/back_color</item>
    <item name="android:colorBackground">@color/back_color</item>
</style>
于 2012-10-25T07:45:33.717 に答える
0

これには、anim フォルダーに次のような回転アニメーションが必要です。

<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@anim/linear_interpolator"
>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="51%"
android:repeatCount="infinite"
android:duration="800" />

</set>

次のように XML でイメージ ビューを作成します。

      <ImageView
       android:id="@+id/loading"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/splash"
       android:layout_centerInParent="true"
       android:layout_gravity="center_horizontal"
       android:layout_marginTop="10dp"
       android:background="@drawable/load_spinner" />

次のコードを使用します。

       Animation mRotateAnim;
       ImageView mImgVwRotatingImage;
           mImgVwRotatingImage = (ImageView) findViewById(R.id.loading);
       mRotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_anim);


private class splashAsync extends AsyncTask<Void, Void, Void> {
    protected void onPreExecute() {
        mImgVwRotatingImage.startAnimation(mRotateAnim);
    }

    protected Void doInBackground(Void... params) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return null;
    }

    protected void onPostExecute(Void v) {
        startActivity(new Intent(first.this, second.class));
        finish();
    }
}
于 2012-10-25T08:03:58.180 に答える