1

Before I asked this question. They said add method. I added but how can I give click event icon0. It is problem for me still..

first question

and these icons are not in xml. They are on draw able folder. this is gives methods can we use it

And this is my trying

package com.myproject.gama;

import java.util.Arrays;

import com.digitalaria.gama.wheel.Wheel;
import com.digitalaria.gama.wheel.WheelAdapter;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
import android.view.View.*;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageButton;
import android.widget.ImageView;

import android.util.Log;

public class SampleWheelActivity extends Activity {

    private static final String TAG = SampleWheelActivity.class.getSimpleName();

    private Wheel wheel;
    public WheelAdapter<Adapter> adapter;
    private Resources res; 
    public int[] icons = { 
         R.drawable.icon1, R.drawable.icon0 , R.drawable.icon2};
    ImageView t;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        init();
      //first example:I try onitemclickListenner but I could not work again click event on icon1

       /*   setListAdapter(new ArrayAdapter(this, R.layout.main ,icons[1] ));

       ListView listView = getListView();
       listView.setTextFilterEnabled(true);

       listView.setOnItemClickListener(new OnItemClickListener() {
       public void onItemClick(AdapterView parent, View view, int position, long id) {               
       Toast.makeText(getApplicationContext(),"hahhaa",            Toast.LENGTH_SHORT).show();               
    }
});
*/
    }

    private void init() {
        res = getApplicationContext().getResources();
        wheel = (Wheel) findViewById(R.id.wheel);       
        wheel.setItems(getDrawableFromData(icons));
        wheel.setWheelDiameter(400);
         //I try this new
              wheel.setOnItemClickListener(new WheelAdapter.OnItemClickListener(){

        @Override
        public void onItemClick(WheelAdapter<?> parent, View view,
                int position, long id) {
         //how can I reach icon1 ?
             //I try it according to Ȃŵåiṩ ĸîŋg answer but still I can not reach icon1
         String selected;

             selected = parent.getItemAtPosition(icons.length + position).toString();
                if( selected.equals("icon0") ){
                      Toast.makeText(getApplicationContext(), ""+"icon0", Toast.LENGTH_SHORT).show();

                }
                else if( selected.equals("icon1")){
                     Toast.makeText(getApplicationContext(), ""+"icon1", Toast.LENGTH_SHORT).show();

                }
                else if(  selected.equals("icon2")){
        Toast.makeText(getApplicationContext(), ""+"icon2", Toast.LENGTH_SHORT).show();

                }


        }});



    }



    private Drawable[] getDrawableFromData(int[] data) {
        Drawable[] ret = new Drawable[data.length];
        for (int i = 0; i < data.length; i++) {
            ret[i] = res.getDrawable(data[i]);
        }
        return ret;
    }

//I try it but how can I give clickevent icon1.. when click icon1 it should go other page. 

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    ImageView iv = new ImageView(this);
    iv.setImageResource(R.drawable.icon1);

            //how can I do when I click this icon1 , it is go other page ???
            // how can do give click action
            // how should I fill this method



}

}

And this is my xml file there is no id icons on xml. They are at draw able folder..

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@drawable/cell_bg"
    >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Hello, GAMA!" />

    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="500dp"
        android:orientation="vertical" 
        android:background="@drawable/belirtec9_2bg"
        android:paddingTop="10px"
    >

    <com.digitalaria.gama.wheel.Wheel
        android:id="@+id/wheel"
        android:paddingTop="10px" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>

    </LinearLayout>

</LinearLayout>
Machavity
  • 30,841
  • 27
  • 92
  • 100
19052013
  • 295
  • 2
  • 13
  • have you tried using setOnItemClickListener? [the documentation](http://developer.digitalaria.com/reference/en/gama/android/com/digitalaria/gama/wheel/Wheel.html#setOnItemClickListener(com.digitalaria.gama.wheel.WheelAdapter.OnItemClickListener)) specifies that. – gkapagunta Mar 16 '14 at 10:51
  • yes but May be I used it wrong.. :(( my english is bad. So sometimes I understand wrong this document.. I should see example. How it is used – 19052013 Mar 16 '14 at 10:56
  • @gkapagunta I put my try about onItemclick on question – 19052013 Mar 16 '14 at 11:49
  • use wheel.setOnItemClickListener(new WheelAdapter.OnItemClickListener(){}); – gkapagunta Mar 16 '14 at 12:01
  • @gkapagunta Yes, I try it but still I do not any idea how can I give click event icon1.. it is not image on xml file.. it is on only drawable folder. I updated my question again – 19052013 Mar 16 '14 at 12:07

2 Answers2

3

try this:

wheel.setOnItemClickListener(new WheelAdapter.OnItemClickListener() {
    @Override
    public void onItemClick(WheelAdapter<?> parent, View view, int position, long id) {
        // Here I am using other activities to be opened on item press,
        // you can use any other action which you like.
        if (position == 0) {
            // First icon is pressed
            Intent intent = new Intent(context, MyNewClass.class);
            startActivity(intent);
        } else if (position == 1) {
            // Second icon is pressed
            Intent intent = new Intent(context, MySecondClass.class);
            startActivity(intent);
        }
    }
});
The Badak
  • 2,010
  • 2
  • 16
  • 28
  • When I click all icons it gives same action.very thanks but How can do this only icon1, icon0... because they are action different :(( Do you give me example on code only icon1. please – 19052013 Mar 16 '14 at 12:35
  • I try to it I update my question but still I can not reach icon1 – 19052013 Mar 16 '14 at 13:12
  • yess it is work very good thanks dude.. :))) and I am new at this form.. How can I do when this icons comes top of page, it should clickable.. Should I asked other question.. or May you help me ^.^ – 19052013 Mar 16 '14 at 13:23
  • sure! I'll try to help you get rid of your problem. :) – The Badak Mar 17 '14 at 02:45
  • So much thanks. :)) as you see if you import this project when you click icon it is go top of circle. how can I do icons should clickable when it is only top of circle – 19052013 Mar 17 '14 at 05:02
  • like touching buttons in layout, when circle is on? – The Badak Mar 17 '14 at 06:25
  • yess =)) like this. When icons top of circle it should click able http://www.code4app.com/photo/508e00cd6803fad324000000_1.png some like this for example icons are top of an it is click able. – 19052013 Mar 17 '14 at 06:42
  • you mean, change icon on press? white to red or any other color – The Badak Mar 17 '14 at 08:19
  • you'll need selector drawable and 2 drawable icons (1=normal state; 2=pressed state) – The Badak Mar 17 '14 at 08:36
1

This code only adds circle on item:

    wheel.setOnItemClickListener(new WheelAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(WheelAdapter<?> parent, View view, int position, long id) {
            ImageView v = (ImageView) parent.getItemAtPosition(position);
            Drawable pd = (Drawable) v.getDrawable();
            Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE);
            //TODO: Set Color and width of circle
            paint.setColor(Color.BLUE);
            paint.setStrokeWidth(4);

            Bitmap mutableBitmap = Bitmap.createBitmap(((BitmapDrawable)pd).getBitmap()).copy(Bitmap.Config.ARGB_8888, true);
            Canvas canvas = new Canvas(mutableBitmap);
            canvas.drawCircle(((BitmapDrawable)pd).getBitmap().getWidth()/2, ((BitmapDrawable)pd).getBitmap().getHeight()/2, 30, paint);
            v.setImageBitmap(mutableBitmap);
        }
    });
The Badak
  • 2,010
  • 2
  • 16
  • 28
  • So sory my bad english I want to said like this http://imageshack.com/a/img21/8687/w3f1.jpg when icon comes in this circle they should be click able only click in pink circle – 19052013 Mar 17 '14 at 22:10
  • I try do something and ı put a code. Keep take out – 19052013 Mar 19 '14 at 09:30
  • Anytime bro, :) you can add me on FB or contact me on WhatsApp for help. fb.com/Awais.is.King +92 3063355690 – The Badak Mar 19 '14 at 12:30