Android GridView Sıra sorunu
05.04.2017 - 09:27
Ödevim için bir Android projesi üzerinde çalışıyorum fakat aşağıdaki hatayla karşılaşıyorum. Yardımcı olursanız sevinirim.
Custom Adapter XML kodlarım
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="90dp"
android:layout_height="90dp">
<ImageView
android:id="@+id/Masa_Resim"
android:layout_height="90dp"
android:layout_width="90dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"></ImageView>
<TextView
android:id="@+id/Masa_No"
android:layout_height="15dp"
android:layout_width="60dp"
android:textAlignment="center"
android:textColor="@android:color/white"
android:layout_marginTop="70dp"
android:layout_centerHorizontal="true"></TextView>
</RelativeLayout>
Custom Adapter Classım
int masaSayisi;
Context c;
masa[] masas;
public Masa_Adapter(Context c, int MasaSayisi,masa[] masas){
this.c=c;
this.masas=masas;
masaSayisi =MasaSayisi;
}
@Override
public int getCount() {
return masaSayisi;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view;
if(convertView==null){
view = new View(c);
view = inflater.inflate(R.layout.masalar,null);
TextView text = (TextView) view.findViewById(R.id.Masa_No);
text.setText("Masa "+(position+1));
ImageView image = (ImageView)view.findViewById(R.id.Masa_Resim);
if(!masas[position].durum)
image.setImageResource(R.drawable.masabos);
else image.setImageResource(R.drawable.masadolu);
}
else view=(View)convertView;
return view;
}
}
Ekran XML kodlarım
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="100dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/MAsalar"
/>
</LinearLayout>
46
Görüntülenme
0 Beğeni