0

嗨,我有一个游戏关卡屏幕..当触摸一个关卡玩时,我需要为其提供指令警报/弹出窗口(可滚动)。

它应该是定制的......喜欢在愤怒的小鸟中弹出......

自己的背景图片没有边框,只有确定按钮

请帮助我我即将发布到 GOOGLEPLAY...

4

3 回答 3

1

我认为您需要这里的代码是一个

mydialog.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

        <Button
            android:id="@+id/ok"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Ok"
            android:layout_gravity="center"
             />

</LinearLayout>

.

Dialog dialog=new Dialog(mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.mydialog);
dialog.getWindow().getAttributes().width = LayoutParams.FILL_PARENT;
dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialogbackground);

Button mOkButton=(Button)dialog.findViewById(R.id.ok);


mOkButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

    //do here what you want to do with ok button click

    }
});

dialogbackground是背景图片

于 2012-05-04T07:14:22.663 回答
1
@Override
protected Dialog onCreateDialog(int id) {
    // TODO Auto-generated method stub
    switch (id) {

    case 0:

        final Dialog mDialog = new Dialog(this);
        mDialog.setContentView(R.layout.customdialog);
        mDialog.setTitle("Custom Dialog");
        mDialog.show();
        mDialog.setCancelable(false);
        final EditText txtUser = (EditText)mDialog.findViewById(R.id.txtUserName);


        Button btnButtonOK = (Button)mDialog.findViewById(R.id.btnOK);
        Button btnButtonCancel = (Button)mDialog.findViewById(R.id.btnCancel);

        btnButtonOK.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                String user = txtUser.getText().toString();
                if (!user.equals(""))
                    {
                    Toast.makeText(getApplicationContext(),
                        user, Toast.LENGTH_LONG).show();
                mDialog.dismiss();
                    }
            }
        });



        btnButtonCancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                mDialog.dismiss();
            }
        });


        break;
}
于 2012-05-04T06:48:41.423 回答
1

您可以使用以下方法制作自己的设计:progress_layer-xml

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" 
   android:layout_marginLeft="10dp"
   android:layout_marginRight="10dp">

   <TextView
       android:id="@+id/textView1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
            android:text="@string/layer_folien"
         android:textAppearance="?android:attr/textAppearanceLarge" />

        <ProgressBar
            android:id="@+id/progressBar1"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/layer_gesamnt"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <ProgressBar
            android:id="@+id/progressBar2"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/dialog_cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="@string/layer_button" />

    </LinearLayout>

和 de Code 来称呼它

final Dialog dialog = new Dialog(PechaKuchaTimerActivity.this);
dialog.show();

final ProgressBar pr_fol = (ProgressBar)  dialog.findViewById(R.id.progressBar1);
final ProgressBar pr_ges = (ProgressBar)  dialog.findViewById(R.id.progressBar2);
final Button button_layerCancel = (Button) dialog.findViewById(R.id.dialog_cancel);
于 2012-05-04T07:00:35.257 回答