I am able to create an AlertDialog. The problem is that my App is all viewed horizontally, but the AlertDialog is showen vertically.
The other GUI parts are drawen using Bitmap, that is why I was able to make them horizontall without specifying it in the main.xml file.
I did add horizontal orientation for linearlayout, but it didn’t help.
The main.xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.app"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" />
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.FLASHLIGHT"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TheActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Creating the dialog looks like this:
{
AboutClick = true;
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle("Pick a color");
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) ;
View layout = inflater.inflate(R.layout.main, null);
builder.setView(layout);
AboutDialog = builder.create();
AboutDialog.show();
}
Any idea why the dialog is displayed vertically and not horizontally?
as you want your app. to always be horizontal, you’ll need to add
android:screenOrientation="landscape"as an attribute in the tag inside the manifest.xml as follows :