3

edit: I asked this question again.. Because I can not take true answer on this question so you can look for full answer

Answer this question

And I try to this icon clickable but I can not do . How can I makte this icons clickevent do you know any way.

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

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();
    }

    private void init() {
        res = getApplicationContext().getResources();
        wheel = (Wheel) findViewById(R.id.wheel);       
        wheel.setItems(getDrawableFromData(icons));
        wheel.setWheelDiameter(400);


    }
    /*I am delete it 
    @Override
    public void onResume(){

        //first try
        ImageView iconsa[] = new ImageView[icons[0]];
        ImageView iconsa1[] = new ImageView[icons[1]];
        ImageView iconsa2[] = new ImageView[icons[1]];

        //second try
        String arrayStr = Arrays.toString (icons);
        String[] aa = arrayStr.split(",");
        String[] strArray = new String[] {arrayStr};
        for(int i=0;i<strArray.length;i++)
        {
            iconsa[i] = new ImageView(wheel.getContext());
             iconsa[i].setOnClickListener(onClick());

        }
    }
   */ 

// I am delete it too

/*  private OnClickListener onClick() {
         Toast.makeText(SampleWheelActivity.this, "test", Toast.LENGTH_SHORT).show();

//   how can ı Reach id on drawable folder icons
        return null;
    } */



    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);

}

}
Community
  • 1
  • 1
19052013
  • 295
  • 2
  • 13

1 Answers1

0

You are using wrong listener. You need to use WheelAdapter.OnItemSelectionUpdatedListener from this Reference.

Here is my working code for same.

public class SampleWheelActivity extends Activity implements OnItemClickListener 
{
    private Wheel wheel;
    private Resources res; 
    private int[] icons = 
        { 
            R.drawable.icon00, R.drawable.icon01, R.drawable.icon02, 
            R.drawable.icon03, R.drawable.icon04, R.drawable.icon05, 
            R.drawable.icon06, R.drawable.icon07, R.drawable.icon08, 
            R.drawable.icon09, R.drawable.icon10, R.drawable.icon11 };

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

        init();
    }

    private void init() 
    {
        res = getApplicationContext().getResources();
        wheel = (Wheel) findViewById(R.id.wheel);

        wheel.setItems(getDrawableFromData(icons));
        wheel.setWheelDiameter(800);
        wheel.setOnItemClickListener(this);
    }

    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;
    }


    // This method will get fire when you click on any image.    
    @Override
    public void onItemClick(WheelAdapter<?> parent, View view, int position, long id) 
    {
        System.out.println ( "id :" + id ); 
    }
}

I am successfully able to get result when clicking on any image with the help of onItemClick().

user2060383
  • 979
  • 1
  • 14
  • 32
  • But what can ı use for reach id. İgamebutton or image drawable do not have click event – 19052013 Mar 07 '14 at 11:04
  • Could you give me example one click action on icon. Becuse ı try it before but ı can not reach id in this method – 19052013 Mar 07 '14 at 11:06
  • And it gives wheel.setOnItemClickListener((com.digitalaria.gama.wheel.WheelAdapter.OnItemClickListener) this); – 19052013 Mar 07 '14 at 14:00
  • The method setOnItemClickListener(WheelAdapter.OnItemClickListener) in the type Wheel is not applicable for the arguments (SampleWheelActivity) – 19052013 Mar 07 '14 at 14:18
  • do you give me your imports – 19052013 Mar 07 '14 at 16:18
  • @19052013, I have give you code, whats the problem ? – user2060383 Mar 10 '14 at 10:29
  • Beforw ı used this method but I can not give click item.. for example could you give me code how can I give clickeven icon1 ?? I try it so Much but ı can not.. :(( – 19052013 Mar 10 '14 at 14:51
  • But mine code is working fine. did you check the logs ? – user2060383 Mar 11 '14 at 03:10
  • Yes but you said syso id but I do not understand how can I give click action with R, id,? What and could you give me example on code only icon1 click evet.. sory my bad English the end I can not give click event icon1 in onItemclick method. I do not idea – 19052013 Mar 11 '14 at 11:13
  • May be you can try this `icons[0]` instead of id of first image. – user2060383 Mar 11 '14 at 12:40
  • I do not have any idea how can I give clickevent id.. :(( I try icon[0].id but could you show me how it ? How can I give click event icon0 could you write code dude – 19052013 Mar 11 '14 at 13:45
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/49483/discussion-between-19052013-and-user2060383) – 19052013 Mar 11 '14 at 13:54