Derzeit habe ich ein Gridlayout, das aus NxN Anzahl von TextViews besteht.Android Zugriff auf Child TextViews von Gridlayout
Ich habe versucht, Zugriff auf einzelne Textansicht Objekte im Raster mit Onclick, aber es funktioniert nicht.
Unten ist ein Ausschnitt aus meinem Code
TextView tv;
final GridLayout gv = (GridLayout) getActivity().findViewById(R.id.map_grid);
gv.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
tv = (TextView)gv.getFocusedChild();//gives me a null object
System.out.println(tv.getId());//error
}
});
es ist, weil getFocusedChild auf diese Weise nicht funktioniert?
Auch meine xml für meine Gridview
<GridLayout
android:id="@+id/map_grid"
android:layout_width="800px"
android:layout_height="600px"
android:layout_marginTop="8dp"
android:columnCount="20"
android:gravity="center"
android:horizontalSpacing="30dp"
android:paddingLeft="20dp"
android:rowCount="15"
android:stretchMode="columnWidth"
android:verticalSpacing="30dp" >
</GridLayout>
Jede Hilfe sehr geschätzt wird!
Hallo, seOnItemClickListener kann nicht aufgelöst werden, wissen Sie, was das Problem ist? Aktuelle Ich habe dies unter onCreate() – Jackelll