android - create custom imageview - listview -


i create below row listview each row has 2 imageviews , user can touch each of them (to open activity).

enter image description here

how can ? must create custom imageview ?

thanks @fashizel @ how create layout that's split diagonally , 2 halves clickable?

layout:

<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">  <framelayout     android:layout_width="100dp"     android:layout_height="100dp"     android:id="@+id/framelayout">      <imageview         android:layout_width="match_parent"         android:layout_height="match_parent"         android:id="@+id/image1"         android:src="@drawable/image01"         />      <imageview         android:layout_width="match_parent"         android:layout_height="match_parent"         android:id="@+id/image2"         android:src="@drawable/image02"         />  </framelayout> 

mainactivity.java:

public class mainactivity extends actionbaractivity {  context mcontext = this;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      framelayout framelayout = (framelayout) findviewbyid(r.id.framelayout);     if (framelayout != null) {         framelayout.setontouchlistener(new view.ontouchlistener() {             @override             public boolean ontouch(view v, motionevent event) {                  if(event.getaction() == motionevent.action_down){                     if(calcplace(event.getx()) < calcplace(event.gety())){                         /// go onclick right triangle                         toast.maketext(mcontext,"onclick right triangle", toast.length_long).show();                     }                     else {                         /// go onclick left triangle                         toast.maketext(mcontext,"onclick left triangle", toast.length_long).show();                     }                 }                 return false;             }         });     } }  private float calcplace(float x){     return 100 - x; }     ... } 

02 image files: 02 triangles

enter image description here

enter image description here

enter image description here

just demo image views, can use views

hope help!


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -