Fehlermeldungen anzeigen

D

dubAUT

Neues Mitglied
0
Hallo Leute,

ich beschäftige ich schon einige Zeit mit der Entwicklung von Applikationen für Adroid, stehe aber nun vor einem simplen Problem, wo mir keine Lösung einfällt:

Auf welche Weise werden Fehlermeldungen (zum Beispiel bei der Validierung von Eingabefeldern) angezeigt? Wie heißen diese Mini-Activities (ich nenne sie mal so), die sich nicht ganz über die ursprüngliche legen?

Vielleicht bekomm ich schnell mal einen Tipp - ich find einfach nicht wrklich was dazu ;-)

Danke schon im Voraus!

Hannes
 
Hi,

ich Tippe einfach mal ins Blaue, dass du die "Toasts" meinst.

Code:
Toast.makeText(this, "Bitte nur Zahlen eingeben!", Toast.LENGTH_LONG).show();
Wenn es das nicht ist dann vllt. AlertDialog? Hier ein Beispiel dazu, alternativ sind auch die ApiDemos recht hilfreich.

Gruß,
Stefan
 
skrhgw schrieb:
Wenn es das nicht ist dann vllt. AlertDialog?
Genau der war es - in den API-Demos habe ich leider nicht wirklich was passendes gefunden ...

Ich hab noch eine Frage, die hier (nur halb) rein passt: Wie kommt man zu zwei gleich großen Buttons nebeneinander am Ende einer Activity, so wie es Google für OK und CANCEL in eigenen Anwendungen macht? Ich finde einfach kein Layout, dass das kann (ich glaube auch, dass die Hintergrundfarbe dieser Button-Zone ein wenig anders ist als in der Activity).

Danke!

Hannes.
 
Hi,

naja Google scheint da bisschen zu tricksen die machen da nen ButtonPanel für. Hab mal bisschen im Source gesucht.

Code:
<!--
/* //device/apps/common/res/layout/alert_dialog.xml
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

---gekürzt---

<LinearLayout android:id="@+id/buttonPanel"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:minHeight="54dip"
        android:orientation="vertical" >     
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="4dip"
            android:paddingLeft="2dip"
            android:paddingRight="2dip" >
            <LinearLayout android:id="@+id/leftSpacer"
                android:layout_weight="0.25"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:visibility="gone" />
            <Button android:id="@+id/button1"
                android:layout_width="0dip"
                android:layout_gravity="left"
                android:layout_weight="1"
                android:maxLines="2"
                android:layout_height="wrap_content" />
            <Button android:id="@+id/button3"
                android:layout_width="0dip"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:maxLines="2"
                android:layout_height="wrap_content" />
            <Button android:id="@+id/button2"
                android:layout_width="0dip"
                android:layout_gravity="right"
                android:layout_weight="1"
                android:maxLines="2"
                android:layout_height="wrap_content" />
            <LinearLayout android:id="@+id/rightSpacer"
                android:layout_width="0dip"
                android:layout_weight="0.25"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:visibility="gone" />
        </LinearLayout>
     </LinearLayout>
</LinearLayout>
Das ist ein Auszug aus der alert_dialog.xml die für die AlertDialoge genutzt wird. Ich hab mal die ganze Datei in den Anhang gesetzt.

Gruß
Stefan
 

Anhänge

  • alert_dialog.txt
    6 KB · Aufrufe: 314
Hi,

ich habe mir hier in einer kleinen Hilfklasse eine statische Methode gemacht um einen Error-Dialog anzuzeigen:

Code:
    public static void displayErrorMessage(CharSequence message, Context context) {
        // display error message
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage(message).setCancelable(false).setPositiveButton(
                context.getResources().getText(R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // do nothing
                    }
                });
        builder.show();
    }

Alternativ kann man heir in dem onClickListener noch ein Event auslösen, z.B. an einem übergebenen Interface eine Methode aufrufen oder so... ist in meinem Fall aber nicht notwendig da ich es nur als reine "Mitteilung" sehe
 

Ähnliche Themen

D
  • Data2006
3 4 5
Antworten
84
Aufrufe
3.644
jogimuc
J
softwaretk
Antworten
3
Aufrufe
1.200
swa00
swa00
A
Antworten
2
Aufrufe
778
Arti851
A
Zurück
Oben Unten