1

ich ein Layout für meine gird Artikel haben, die eine lineare Layout und dass enthält eine TextviewFalsche Ansicht zurückgegeben werden

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="120dp" 
    android:minHeight="120dp" 
    android:background="@drawable/bg_all_white_rounded_gray" 
    android:gravity="center" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/ui_row" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_margin="@dimen/margin_social_logo" 
     android:gravity="center" 
     android:text="Family Friends" 
     android:textColor="@color/colorPrimaryDark" 
     android:textSize="@dimen/font_text" 
     android:visibility="visible" /> 

</LinearLayout>` 

Wenn ich inflater.inflate(R.layout.main_grid_row, parent, false); von Adapter Aufruf gibt es Aussicht vom Typ

android.support.design.internal.NavigationMenuView 

anstelle eines linearen Layouts.

@Override 
public View getView(final int position, final View convertView, final ViewGroup parent) { 
    View rowView = convertView; 
    ViewHolderCategories holder = null; 
    if (convertView == null) { 
     rowView = mInflater.inflate(R.layout.main_grid_row, parent, false); 
     holder = new ViewHolderCategories(mContext, rowView); 
     rowView.setTag(holder); 
    } else { 
     holder = (ViewHolderCategories) rowView.getTag(); 
    } 
    MainCategory data = mAllData.get(position); 
    holder.updateView(data.getCategoryName()); 

    return rowView; 
} 

Ich bin nicht in der Lage, warum seine auf Figur anstelle eines Liners Layout eine andere Ansicht der Rückkehr

+0

können Sie den vollständigen Code der XML-Datei posten? –

+0

Ich habe gepostet, aber es ist nicht sichtbar. Kannst du meine Frage bearbeiten? – SAIR

+1

Versuchen Sie, Ihren Build zu reinigen, nicht, dass ich denke, dass es funktioniert, aber es kann nicht schaden: P – zgc7009

Antwort

0

Versuchen Sie folgendes:

rowView = LayoutInflater.from(parent.getContext()).inflate(R.layout.main_grid_row, null); 
0

Dies ist meine Aktivität Layout-Datei, in dem ich die hinzugefügt haben Rasteransicht.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_gravity="center" 
android:background="@color/colorAppTheme"> 

<GridView 
    android:id="@+id/grid_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    android:columnWidth="90dp" 
    android:horizontalSpacing="10dp" 
    android:numColumns="2" 
    android:stretchMode="columnWidth" 
    android:verticalSpacing="10dp" /></RelativeLayout> 

nur entfernt das android:gravity="center" Formular GridView und es funktioniert gut. Keine Ahnung, wie es verwandt ist, aber ich dachte, die Antwort zu posten.

Verwandte Themen