java - Android tablelayout click listener for cell content -


i have 3x3 gridview custom linearlayouts within. want layout , search on internet it's not possible gridview because of column span. used gridview because of onclicklistener method: when user click on 1 of grid cell, new activity starts(not same activity, it's main menu). possible in tablelayout? if click on cell if spanned can call onclick method? i've searched web solutions, of i've found clicking on tablerow(which not me if there 3 custom layouts in 1 row).

my layout tablelayout:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/background_light" android:orientation="vertical" >  <imageview     android:id="@+id/headerpicture"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:contentdescription="@string/imagestring"     android:src="@drawable/bicaj" />  <tablelayout     android:id="@+id/maingrid"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:layout_gravity="center"     android:numcolumns="3" >      <tablerow         android:id="@+id/mainfirstrow"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:padding="5dip" >          <linearlayout             android:id="@+id/mainonline"             android:layout_width="match_parent"             android:layout_height="wrap_content" >             <imageview                 android:id="@+id/mainicononline"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:contentdescription="@string/main_page_icon_descp" />              <textview                 android:id="@+id/maintextonline"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:textsize="12sp" />         </linearlayout>     </tablerow> . . . .     </tablelayout> </linearlayout> 

you can add clicklisteners imageview

.....     <linearlayout                 android:id="@+id/mainonline"                 android:layout_width="match_parent"                 android:layout_height="wrap_content" >                 <imageview                     android:id="@+id/mainicononline"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:contentdescription="@string/main_page_icon_descp" /> ...... 

and in activity

imageview butt1 = (imageview) findviewbyid(r.id.mainicononline);          butt1.setonclicklistener(this);  @override     public void onclick(view v) {         if (v.getid() == r.id.mainicononline) {              intent = new intent(this, secondactivityclass);         startactivity(i);          }      } 

this should work


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -