Textviev aufklappen

L

loocker

Neues Mitglied
3
Hi,
ich bin gerade dabei eine App zu entwickeln. Jetzt hab ich eine Textview erstellt die die Daten aus der DB anzeigt. Soweit so gut, jetzt ist das ziemlich viel Text und belegt fast den ganzen Bildschirm, was nicht so toll aussieht. Habe in den Android Referenzen gelessen das man die Textview auf eine bestimmt Anzahl von Zeile beschränken kann,das wäre noch die Alternative. Ich würde es aber gerne so machen, das nur so drei Zeilen angezeigt werden und der Rest wenn man drauf klickt, so wie im Google Play bei der Beschreibung, wenn die länger sind. Habe nichts finden können. Hoffe jemand kann helfen.

Gesendet von meinem GT-I9000 mit Tapatalk
 
das ist eher keine standardkomponente. das verhalten musst selbst implementieren.
 
Ok, eine Idee wie man da am besten ran geht?

Gesendet von meinem GT-I9000 mit Tapatalk
 
naja ich würd mir eine custom komponente bauen,

linearlayout
textview
pfeil zum öffnen

dann einfach die zeilenanzahl festlegen. zu beginn 3 zeilen - bei einem klick dann alle zeilen.

es ist aber gut möglich, dass man im netz den code für so eine komponente finden kann. ist aber sicher relativ schnell implementiert
 
Hjetzt nochmal in english gegooglet und diese Seite widget - How to implement expandable panels in Android? - Stack Overflow gefunden.
Habe das mal 1 zu 1 übernommen, aber wenn ich eine Layout xml erstelle und diesen Code dort einfüge bekomme ich in der rot makierten Zeile folgende Fehlermeldung in eclipse:
AndroidManifest: Ignoring unknown 'com.example.androidapp.widgets.ExpandablePanel' XML element

Code:
[COLOR=red]<com.example.androidapp.widgets.ExpandablePanel[/COLOR][COLOR=red] [/COLOR]
    android:orientation="vertical" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    example:handle="@+id/expand" 
    example:content="@+id/value" 
    example:collapsedHeight="50dip"> 
    <TextView 
        android:id="@id/value" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:maxHeight="50dip" 
        /> 
    <Button 
        android:id="@id/expand" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="More" /> 
</com.example.androidapp.widgets.ExpandablePanel>

Jemand eine Idee woran das liegt?
 
Öh lol? :D
Schon mal Programmiert? :>

[Habe mir die Seite nicht angeschaut]
Der erste Teil sagt ja imme aus welcher View/Widget - wie auch immer - du benutzen willst. Also z.b. <Button> oder <TextView>. Beide sind Standardkomponenten von Android => Die Xml kann damit was anfangen.

Dein Widget, musst du natrülich erst erstellen.
D.h. dein Widget-Programmcode (Also ExpandablePanel) muss im Package "com.example.androidapp" leigen..

Iwie muss also stehen, wie das Widget "ExpandablePanel" auszusehen - als Java-Code - hat!

Gruß
 
Die ExpendablePanel class und die attrs XML hab ich schon angelegt gehabt. Deswegen wundere ich mich ja über den Fehler.

Gesendet von meinem GT-I9000 mit Tapatalk
 
Dann musst du nochmal genauer auf dein Projekt gucken.

packae müsste den namen haben: "com.example.androidapp.widgets"
die classe dazu musst: "ExpandablePanel"
heißen..

Dann müsste es gehen.. Schau einfach nochmal genauer drauf ;) Du übersiehst bestimmt nur etwas..

Gruß
 
habe noch mal alles geprüft, ist alles richtig angelegt, denke ich.
Habe ein Package angelegt
"package
com.example.androidapp.widgets; ", darin die Classe
ExpandablePanel und unter values die attrs.xml und in layout eine main.xml wo ich den unten stehenden Code eingefügt habe. Bekomme den Fehler "Description Resource Path Location Type
error: Error parsing XML: unbound prefix main.xml /Probe/res/layout "
in dieser Zeile "<com.example.androidapp.widgets.ExpandablePanel" und als warnings noch "Description Resource Path Location Type
Attribute is missing the Android namespace prefix main.xml /Probe/res/layout " bei allen Zeilen zwichen Button und textview. Echt komisch. Muss man so custom layouts noch irgendwie in die Android manifest eintragen?

 
Keiner eine Idee wo der Fehler noch liegen könnte?

Gesendet von meinem GT-I9000 mit Tapatalk
 
Poste doch mal deinen Code + XML dann sieht man vielleicht was
 
Hier die ExpandablePanel Klasse
Code:
package com.example.androidapp.widgets; 
 
import android.content.Context; 
import android.content.res.TypedArray; 
import android.util.AttributeSet; 
import android.view.View; 
import android.view.animation.Animation; 
import android.view.animation.Transformation; 
import android.widget.LinearLayout; 
 
import com.example.androidapp.widgets.*; 
 
public class ExpandablePanel extends LinearLayout { 
 
    private final int mHandleId; 
    private final int mContentId; 
 
    private View mHandle; 
    private View mContent; 
 
    private boolean mExpanded = true; 
    private int mCollapsedHeight = 0; 
    private int mContentHeight = 0; 
 
    public ExpandablePanel(Context context) { 
        this(context, null); 
    } 
 
    public ExpandablePanel(Context context, AttributeSet attrs) { 
        super(context, attrs); 
 
        TypedArray a = context.obtainStyledAttributes(attrs, 
            R.styleable.ExpandablePanel, 0, 0); 
 
        // How high the content should be in "collapsed" state 
        mCollapsedHeight = (int) a.getDimension( 
            R.styleable.ExpandablePanel_collapsedHeight, 0.0f); 
 
        int handleId = a.getResourceId(R.styleable.ExpandablePanel_handle, 0); 
        if (handleId == 0) { 
            throw new IllegalArgumentException( 
                "The handle attribute is required and must refer " 
                    + "to a valid child."); 
        } 
 
        int contentId = a.getResourceId(R.styleable.ExpandablePanel_content, 0); 
        if (contentId == 0) { 
            throw new IllegalArgumentException( 
                "The content attribute is required and must refer " 
                    + "to a valid child."); 
        } 
 
        mHandleId = handleId; 
        mContentId = contentId; 
 
        a.recycle(); 
    } 
 
    @Override 
    protected void onFinishInflate() { 
        super.onFinishInflate(); 
 
        mHandle = findViewById(mHandleId); 
        if (mHandle == null) { 
            throw new IllegalArgumentException( 
                "The handle attribute is must refer to an" 
                    + " existing child."); 
        } 
 
        mContent = findViewById(mContentId); 
        if (mContent == null) { 
            throw new IllegalArgumentException( 
                "The content attribute is must refer to an" 
                    + " existing child."); 
        } 
 
        mHandle.setOnClickListener(new PanelToggler()); 
    } 
 
    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
        if (mContentHeight == 0) { 
            // First, measure how high content wants to be 
            mContent.measure(widthMeasureSpec, MeasureSpec.UNSPECIFIED); 
            mContentHeight = mContent.getMeasuredHeight(); 
        } 
 
        // Then let the usual thing happen 
        super.onMeasure(widthMeasureSpec, heightMeasureSpec); 
    } 
 
    private class PanelToggler implements OnClickListener { 
        public void onClick(View v) { 
            Animation a; 
            if (mExpanded) { 
                a = new ExpandAnimation(mContentHeight, mCollapsedHeight); 
            } else { 
                a = new ExpandAnimation(mCollapsedHeight, mContentHeight); 
            } 
            a.setDuration(500); 
            mContent.startAnimation(a); 
            mExpanded = !mExpanded; 
        } 
    } 
 
    private class ExpandAnimation extends Animation { 
        private final int mStartHeight; 
        private final int mDeltaHeight; 
 
        public ExpandAnimation(int startHeight, int endHeight) { 
            mStartHeight = startHeight; 
            mDeltaHeight = endHeight - startHeight; 
        } 
 
        @Override 
        protected void applyTransformation(float interpolatedTime, 
            Transformation t) { 
            android.view.ViewGroup.LayoutParams lp = mContent.getLayoutParams(); 
            lp.height = (int) (mStartHeight + mDeltaHeight * interpolatedTime); 
            mContent.setLayoutParams(lp); 
        } 
 
        @Override 
        public boolean willChangeBounds() { 
            // TODO Auto-generated method stub 
            return true; 
        } 
    } 
}

Dann die Activity welche das Layout (main.xml) beutzt
Code:
package com.example.androidapp.widgets;
import android.app.Activity;
import android.os.Bundle;
public class ProbeActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

Die main.xml in res/layout
Code:
[SIZE=2][COLOR=#008080]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080][LEFT]<?[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]xml[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]version[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000]=[/COLOR][/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"1.0"[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]encoding[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000]=[/COLOR][/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"utf-8"[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]?>[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]
[/LEFT]
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080][LEFT]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]com.example.androidapp.widgets.ExpandablePanel [COLOR=red]Hier wird der Fehler angezeigt![/COLOR][/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:orientation[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"vertical"[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:layout_height[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"wrap_content"[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:layout_width[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"fill_parent"[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]example:handle[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"@+id/expand"[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]example:content[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"@+id/value"[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]example:collapsedHeight[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"50dip"[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]TextView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:id[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"@id/value"[/I][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:layout_width[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"fill_parent"[/I][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:layout_height[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"wrap_content"[/I][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:maxHeight[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"50dip"[/I][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]/>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]Button[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:id[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"@id/expand"[/I][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:layout_width[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"wrap_content"[/I][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:layout_height[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"wrap_content"[/I][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
[/SIZE][U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]android:text[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"More"[/I][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]/>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/LEFT]
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]</[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]com.example.androidapp.widgets.ExpandablePanel[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]>

[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008080][/COLOR][/SIZE]
und dann noch die attrs.xml in res/values
Code:
[SIZE=2][COLOR=#008080]
[LEFT][SIZE=2][COLOR=#008080]<?[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][LEFT][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]xml[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]version[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"1.0"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]encoding[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"utf-8"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]?>[/COLOR][/SIZE][/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]<[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][LEFT][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]resources[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]>[/COLOR][/SIZE][/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]declare-styleable[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]name[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"ExpandablePanel"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]attr[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]name[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"handle"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]format[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"reference"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]/>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]attr[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]name[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"content"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]format[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"reference"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]/>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]attr[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]name[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"collapsedHeight"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]format[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"dimension"[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]/>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]</[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]declare-styleable[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]>[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]</[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]resources[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]>[/COLOR][/SIZE]
[/COLOR][/SIZE]
 
Du musst in deiner main.xml im Root Element deine Namespaces (android und example) definieren.
Das muss man immer, wenn in der xml Datei Attribute mit Doppelpunkt vorkommen.

In dem Stackoverflowartikel fehlt es vermutlich deshalb, weil dort das Panel nicht Rootelement war.

Übrigens:
Code:
package com.example.androidapp.widgets;
...
import com.example.androidapp.widgets.*;
Ist etwas redundant :D
 
Zuletzt bearbeitet:
habe es jetzt mal so abgeändert
Code:
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]<[/COLOR][/SIZE]
[LEFT][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f7f][SIZE=2][COLOR=#3f7f7f]com.example.androidapp.widgets.ExpandablePanel[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]xmlns:android[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"http://schemas.android.com/apk/res/android"[/COLOR][/SIZE][/COLOR][/SIZE][/I]

[U][SIZE=2][COLOR=#7f007f][SIZE=2][COLOR=#7f007f]xmlns:app[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]="[/SIZE][I][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff][URL]http://schemas.android.com/apk/res/com.example.androidapp.widgets[/URL]"[/COLOR][/SIZE][/COLOR][/SIZE][/I][/U][/LEFT]

...

bekomme aber immer noch den Fehler angezeigt:
error: Error parsing XML: unbound prefix



 
Wenn du "app:" als Namespace definierst, kannst du nicht "example:" als Namespace nutzen.
 
  • Danke
Reaktionen: loocker
Ich glaub ich habe es kapiert. Der xmlns ist quasi nur eine Abkürzung. Also kommt example als namespace dort hin damit ich in meiner xml view, bzw. Wie bei den Standards von Android nicht immer den ganzen Pfad angeben muss, sondern nur den zuvor definierten Namespace. Werde es gleich mal ausprobieren, wenn ich zu hause bin.

Gesendet von meinem GT-I9000 mit Tapatalk
 
Nach der Änderung hat es sofort geklappt. :D
 

Ähnliche Themen

J
Antworten
3
Aufrufe
889
Jaiel
Jaiel
S
  • smartjolka
Antworten
0
Aufrufe
798
smartjolka
S
J
Antworten
10
Aufrufe
2.561
joschika77
J
Zurück
Oben Unten