Как я могу постоянно вращать мой пользовательский AlertDialog? - PullRequest
0 голосов
/ 30 августа 2011

У меня есть собственный диалог. Я использую следующий код для его создания в методе "onCreateDialog":

Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this,
            android.R.style.Theme_Light_NoTitleBar_Fullscreen));

    LayoutInflater inflater = LayoutInflater.from(this);
    final View productsView = inflater.inflate(
            R.layout.dialog_photo_gallery,
            null);
    builder.setView(productsView);
    galProducts = (Gallery) productsView.findViewById(R.id.galProducts);
    ...

Я использовал ссылку для создания пользовательского LinearLayout, который поддерживает вращение.

Я хочу использовать свой собственный класс LinearLayout и установить в нем свой макет ресурса? Я не хочу объявлять мои элементы управления динамически в исходном коде. Я хочу сделать что-то вроде этого:

RotateLinearLayout myLayout= new RotateLinearLayout(this);
myLayout.setResourceView(R.layout.dialog_photo_gallery);

Как я могу это сделать?

Как одновременно использовать AlertDialog.Builder и мой RotateLinearLayout?

1 Ответ

1 голос
/ 30 августа 2011

Вам просто нужно обернуть элементы управления, описанные в R.layout.dialog_photo_gallery, в свою RotateLinearLayout

примерно так:

<com.xxx.RotateLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                       android:layout_width="fill_parent"
                       android:layout_height="fill_parent">
 <Gallery android:id="@+id/galProducts
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"/>
</com.xxx.RotateLinearLayout>

И затем:

public class MyDialog extends AlertDialog {
    public MyDialog(Context context) {
        super(context);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_photo_gallery, null);
        setView(view);
        galProducts = (Gallery) view.findViewById(R.id.galProducts);       
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...