package com.carouseldemo.main; |
import com.carouseldemo.controls.Carousel; |
import com.carouseldemo.controls.CarouselAdapter; |
import com.carouseldemo.controls.CarouselAdapter.OnItemClickListener; |
import android.app.Activity; |
import android.os.Bundle; |
import android.view.View; |
import android.widget.TextView; |
import android.widget.Toast; |
public class MainActivity extends Activity { |
/** Called when the activity is first created. */ |
TextView textView; |
@Override |
public void onCreate(Bundle savedInstanceState) { |
super .onCreate(savedInstanceState); |
setContentView(R.layout.main); |
textView = (TextView) findViewById(R.id.textview); |
Carousel carousel = (Carousel) findViewById(R.id.carousel); |
carousel.setOnItemClickListener( new OnItemClickListener() { |
@Override |
public void onItemClick(CarouselAdapter<?> parent, View view, |
int position, long id) { |
String result = "点击图片是--" + "Position=" + (position + 1 ) + "张" ; |
Toast.makeText(MainActivity. this , result, Toast.LENGTH_SHORT) |
.show(); |
if (position == 2 ) { |
String text = "您只需要更改res/values/arrays.xml文件夹,\n当中图片资源即可.\n这个TextView用于测试效果.\n这里的编号是从0开始的" ; |
textView.setText(text); |
} else { |
textView.setText( "" ); |
} |
} |
}); |
} |
} |