I have a custom dialog. I use the following code to create it in "onCreateDialog" method:
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);
...
I have used the link for creating a custom LinearLayout that supports rotation.
I want to use my custom LinearLayout class and set my resource layout to it? I do not want to declare my controls dynamically in the source code. I want to do something li开发者_运维问答ke this:
RotateLinearLayout myLayout= new RotateLinearLayout(this);
myLayout.setResourceView(R.layout.dialog_photo_gallery);
How can I do that?
How can I use AlertDialog.Builder and my RotateLinearLayout Simultaneously?
You just need to wrap up your controls described in R.layout.dialog_photo_gallery to your RotateLinearLayout
something like that:
<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>
And then:
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);
}
}
精彩评论