Gelöschter Account
- Forum-Beiträge: 460
03.07.2010, 19:17:50 via Website
03.07.2010 19:17:50 via Website
Hallo ich versuche gerade einen Custom Dialog zu erstellen,der über den Menü-Button "Information" geöffnet werden soll.
Dazu habe ich folgendes Layout erstellt:
layout/custom_dialog.xml
Nun soll folgendes ausgeführt werden:
Leider gibt es immer einen FC....
Jemand eine idee
Dazu habe ich folgendes Layout erstellt:
layout/custom_dialog.xml
1<?xml version="1.0" encoding="UTF-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:id="@+id/layout_root"
4 android:orientation="horizontal"
5 android:layout_width="fill_parent"
6 android:layout_height="fill_parent"
7 android:padding="10dp"
8 >
9 <ImageView android:id="@+id/image"
10 android:layout_width="wrap_content"
11 android:layout_height="fill_parent"
12 android:layout_marginRight="10dp"
13 />
14 <TextView android:id="@+id/text"
15 android:layout_width="wrap_content"
16 android:layout_height="fill_parent"
17 android:textColor="#FFF"
18 />
19</LinearLayout>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:id="@+id/layout_root"
4 android:orientation="horizontal"
5 android:layout_width="fill_parent"
6 android:layout_height="fill_parent"
7 android:padding="10dp"
8 >
9 <ImageView android:id="@+id/image"
10 android:layout_width="wrap_content"
11 android:layout_height="fill_parent"
12 android:layout_marginRight="10dp"
13 />
14 <TextView android:id="@+id/text"
15 android:layout_width="wrap_content"
16 android:layout_height="fill_parent"
17 android:textColor="#FFF"
18 />
19</LinearLayout>
Nun soll folgendes ausgeführt werden:
1AlertDialog.Builder builder2;
2 AlertDialog alert2;
3
4 Context mContext = getApplicationContext();
5 LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
6 View layout = inflater.inflate(R.layout.custom_dialog,
7 (ViewGroup) findViewById(R.id.layout_root));
8
9 TextView text = (TextView) layout.findViewById(R.id.text);
10 text.setText("Hello, this is a custom dialog!");
11 ImageView image = (ImageView) layout.findViewById(R.id.image);
12 image.setImageResource(R.drawable.icon);
13
14 builder2 = new AlertDialog.Builder(mContext);
15 builder2.setView(layout);
16 alert2 = builder2.create();
2 AlertDialog alert2;
3
4 Context mContext = getApplicationContext();
5 LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
6 View layout = inflater.inflate(R.layout.custom_dialog,
7 (ViewGroup) findViewById(R.id.layout_root));
8
9 TextView text = (TextView) layout.findViewById(R.id.text);
10 text.setText("Hello, this is a custom dialog!");
11 ImageView image = (ImageView) layout.findViewById(R.id.image);
12 image.setImageResource(R.drawable.icon);
13
14 builder2 = new AlertDialog.Builder(mContext);
15 builder2.setView(layout);
16 alert2 = builder2.create();
Leider gibt es immer einen FC....
Jemand eine idee
— geändert am 03.07.2010, 19:18:03
Grüße Alexander
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.