this gridview i'm trying make. letter tiles must distinct textviews corners rounded.
http://www.expertsmind.com/cmsimages/125_boggle.png
and how far have come.
public class mainactivity extends activity { gridview grid; static final string[] letters = new string[] {"b","a","t","t","t"}; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); grid = (gridview) findviewbyid(r.id.mygrid); arrayadapter adapter = new arrayadapter(this, android.r.layout.simple_list_item_1, letters); grid.setadapter(adapter); grid.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview parent, view v, int position, long id) { toast.maketext(getapplicationcontext(), ((textview) v).gettext(), toast.length_short).show(); v.setbackgroundcolor(color.cyan); } }); }
}
my xml file,
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity"> <gridview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mygrid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:columnwidth="50dp" android:gravity="center" android:numcolumns="auto_fit" android:stretchmode="columnwidth" android:background="@drawable/rounded"> </gridview> </relativelayout>
now board i'm trying make like,
f r e
and 5 digit letter it'll show as,
e g h t
i'm trying set layout java file dynamically. please provide suggestion or example code. don't think understand part how can individual items of arrayadapter, can set it's color yellow or rounded corners. if please explain little it'll great help. in advance.
gridview
won't layout 5 letter example want, do:
e g h t
i.e. columns have aligned. may need use recyclerview
achieve this.
for rounded corners, need background rounded corners on textview.
Comments
Post a Comment