单击轮播视图的图像

时间:2013-07-31 04:59:37

标签: android carousel

我创建了应用。这是在轮播视图中显示图像。我想点击旋转木马视图的图像&去网站。

怎么做。 我按照以下方式将图像加载到我的轮播视图中。]

public class LazyAdapter extends BaseAdapter {

    private Activity activity;
    private String[] data;
    private static LayoutInflater inflater=null;
    String dirUrl[];
    public ImageLoader imageLoader; 
    public ViewGroup carousel;
    HorizontalCarouselLayout carousel_layout_event;
    int widthScreen,heightScreen;

    public LazyAdapter(Activity a, String[] d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    public int getCount() {
        return data.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }
    public void getDimensionScreen(int width,int height){
      widthScreen=width;
      heightScreen=height;

    }
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.showsmain, null);

        ImageView image=(ImageView)vi.findViewById(R.id.imageView1);     
        imageLoader.DisplayImage(data[position], image);
        int width = Double.valueOf(widthScreen*1.4).intValue();
        int height = Double.valueOf(heightScreen*1.2).intValue();
        imageLoader.getDimension(width, height);

        return vi;
    }

}

图像视图的布局是,

 <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:scaleType="fitXY"
        android:layout_alignParentTop="true" />

我的轮播布局xml文件是,

<com.touchmenotapps.carousel.simple.HorizontalCarouselLayout
        android:id="@+id/carousel_layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/relativeLayout1"
         android:layout_marginTop="@dimen/marginTopUserImagePlayeractivity" >
    </com.touchmenotapps.carousel.simple.HorizontalCarouselLayout>

请立即给我答案,我坚持这个问题。

感谢.........

这里我按照以下方式将carousel适配器设置在我的mainactivity中,

public void displayHomeScreen(View v) {

        inflatedView.setVisibility(View.INVISIBLE);
        footerlayout.setVisibility(View.VISIBLE);
        headerlayout.setVisibility(View.VISIBLE);
        carousel_layout.setVisibility(View.INVISIBLE);
        progressbar.setVisibility(View.VISIBLE);
        layout.setVisibility(View.VISIBLE);

        clickCountHome = clickCountHome + 1;

        ((ViewGroup) carousel_layout_home).removeAllViews();
        UIStateManager.getInsatance().homeClickedUIChange();

        RelativeLayout rLayout = (RelativeLayout) findViewById(R.id.relLayoutPlayerActivity);
        Resources res = getResources(); // resource handle
        Drawable drawable = res.getDrawable(R.drawable.loggedinscreen);
        rLayout.setBackgroundDrawable(drawable);

        if (clickCountHome >= 1 && xmlHome != null) {
            new CountDownTimer(1000, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {

                }

                @Override
                public void onFinish() {
                    progressbar.setVisibility(View.INVISIBLE);
                    layout.setVisibility(View.INVISIBLE);
                }
            }.start();
            carousel_layout_home.setStyle(mStyle);
            carousel_layout_home.setAdapter(adapterHome);
            carousel_layout_home
                    .setOnCarouselViewChangedListener(new CarouselInterface() {
                        @Override
                        public void onItemChangedListener(View v, int position) {
                            positionHome = position;


                            v.setOnLongClickListener(new View.OnLongClickListener() {

                                @Override
                                public boolean onLongClick(View v) {
                                    Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                                    myWebLink.setData(Uri.parse(dirHome[0]));
                                    startActivity(myWebLink);
                                    return false;
                                }

                            });
                        }


                    });

这里我通过解析xml来获取dirHome的网址.......

你能给出答案吗?我做了上面的事情。但它并没有完美地运作............

0 个答案:

没有答案