本文整理匯總了Java中cn.addapp.pickers.picker.SinglePicker.setOnItemPickListener方法的典型用法代碼示例。如果您正苦於以下問題:Java SinglePicker.setOnItemPickListener方法的具體用法?Java SinglePicker.setOnItemPickListener怎麽用?Java SinglePicker.setOnItemPickListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cn.addapp.pickers.picker.SinglePicker
的用法示例。
在下文中一共展示了SinglePicker.setOnItemPickListener方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showConstellationPicker
import cn.addapp.pickers.picker.SinglePicker; //導入方法依賴的package包/類
/**
* 星座選擇器
* @param activity
* @param current 當前星座
* @param listener
*/
public void showConstellationPicker(Activity activity,String current,final ItemListener listener){
SinglePicker<String> picker = new SinglePicker<>(activity,
new String[]{"水瓶座", "雙魚座", "白羊座", "金牛座", "雙子座", "巨蟹座", "獅子座",
"處女座", "天秤座", "天蠍座", "射手座", "摩羯座"});
picker.setCanLoop(false);//不禁用循環
picker.setWheelModeEnable(true);
picker.setWidth(picker.getScreenWidthPixels());
picker.setLineVisible(false);
picker.setTopBackgroundColor(0xFFFEE61B);
picker.setTitleText("星座");
picker.setTitleTextColor(0xFF000000);
picker.setTitleTextSize(14);
picker.setCancelTextColor(0xFF4D4D4D);
picker.setCancelTextSize(14);
picker.setSubmitTextColor(0xFF4D4D4D);
picker.setPressedTextColor(0xFF4D4D4D);
picker.setSubmitTextSize(14);
picker.setTopHeight(48);
picker.setSelectedTextColor(0xFFFEE61B);
picker.setSelectedItem(current);
picker.setOnItemPickListener(new OnItemPickListener<String>() {
@Override
public void onItemPicked(int index, String item) {
listener.onItemPicked(index,item);
}
});
picker.show();
}
示例2: showSexPicker
import cn.addapp.pickers.picker.SinglePicker; //導入方法依賴的package包/類
/**
* 顯示性別選擇器
* @param activity
* @param sex
* @param listener
*/
public void showSexPicker(Activity activity,String sex,final ItemListener listener){
SinglePicker<String> picker = new SinglePicker<>(activity,
new String[]{"男", "女"});
picker.setCanLoop(false);//不禁用循環
picker.setWheelModeEnable(true);
picker.setWidth(picker.getScreenWidthPixels());
picker.setLineVisible(false);
picker.setTopBackgroundColor(0xFFFEE61B);
picker.setTitleText("性別");
picker.setTitleTextColor(0xFF000000);
picker.setTitleTextSize(14);
picker.setCancelTextColor(0xFF4D4D4D);
picker.setCancelTextSize(14);
picker.setSubmitTextColor(0xFF4D4D4D);
picker.setPressedTextColor(0xFF4D4D4D);
picker.setSubmitTextSize(14);
picker.setTopHeight(48);
picker.setSelectedTextColor(0xFFFEE61B);
picker.setSelectedItem(sex);
picker.setOnItemPickListener(new OnItemPickListener<String>() {
@Override
public void onItemPicked(int index, String item) {
listener.onItemPicked(index,item);
}
});
picker.show();
}
示例3: showIndustryPicker
import cn.addapp.pickers.picker.SinglePicker; //導入方法依賴的package包/類
/**
* 顯示所在行業選擇器
* @param activity
* @param listener
*/
public void showIndustryPicker(Activity activity,final ItemListener listener){
SinglePicker<String> picker = new SinglePicker<>(activity,
new String[]{"學生","文化/藝術","影視/娛樂","金融",
"醫藥/健康","工業/製造業","IT/互聯網/通信",
"媒體/公關","個體經營","教育/科研","其他"});
picker.setCanLoop(false);//不禁用循環
picker.setWheelModeEnable(true);
picker.setWidth(picker.getScreenWidthPixels());
picker.setLineVisible(false);
picker.setTopBackgroundColor(0xFFFEE61B);
picker.setTitleText("所在行業");
picker.setTitleTextColor(0xFF000000);
picker.setTitleTextSize(14);
picker.setCancelTextColor(0xFF4D4D4D);
picker.setCancelTextSize(14);
picker.setSubmitTextColor(0xFF4D4D4D);
picker.setPressedTextColor(0xFF4D4D4D);
picker.setSubmitTextSize(14);
picker.setTopHeight(48);
picker.setSelectedTextColor(0xFFFEE61B);
picker.setOnItemPickListener(new OnItemPickListener<String>() {
@Override
public void onItemPicked(int index, String item) {
listener.onItemPicked(index,item);
}
});
picker.show();
}
示例4: showEmotionalPicker
import cn.addapp.pickers.picker.SinglePicker; //導入方法依賴的package包/類
/**
* 顯示情感狀態選擇器
* @param activity
* @param emotional
* @param listener
*/
public void showEmotionalPicker(Activity activity,String emotional,final ItemListener listener){
SinglePicker<String> picker = new SinglePicker<>(activity,
new String[]{"保密","單身","已婚","同性"});
picker.setCanLoop(false);//不禁用循環
picker.setWheelModeEnable(true);
picker.setWidth(picker.getScreenWidthPixels());
picker.setLineVisible(false);
picker.setTopBackgroundColor(0xFFFEE61B);
picker.setTitleText("情感狀態");
picker.setTitleTextColor(0xFF000000);
picker.setTitleTextSize(14);
picker.setCancelTextColor(0xFF4D4D4D);
picker.setCancelTextSize(14);
picker.setSubmitTextColor(0xFF4D4D4D);
picker.setPressedTextColor(0xFF4D4D4D);
picker.setSubmitTextSize(14);
picker.setSelectedItem(emotional);
picker.setTopHeight(48);
picker.setSelectedTextColor(0xFFFEE61B);
picker.setOnItemPickListener(new OnItemPickListener<String>() {
@Override
public void onItemPicked(int index, String item) {
listener.onItemPicked(index,item);
}
});
picker.show();
}
示例5: onConstellationPicker
import cn.addapp.pickers.picker.SinglePicker; //導入方法依賴的package包/類
public void onConstellationPicker(View view) {
boolean isChinese = Locale.getDefault().getDisplayLanguage().contains("中文");
SinglePicker<String> picker = new SinglePicker<>(this,
isChinese ? new String[]{
"水瓶座", "雙魚座", "白羊座", "金牛座", "雙子座", "巨蟹座",
"獅子座", "處女座", "天秤座", "天蠍座", "射手座", "摩羯座"
} : new String[]{
"Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "Cancer",
"Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn"
});
picker.setCanLoop(false);//不禁用循環
picker.setTopBackgroundColor(0xFFEEEEEE);
picker.setTopHeight(50);
picker.setTopLineColor(0xFF33B5E5);
picker.setTopLineHeight(1);
picker.setTitleText(isChinese ? "請選擇" : "Please pick");
picker.setTitleTextColor(0xFF999999);
picker.setTitleTextSize(12);
picker.setCancelTextColor(0xFF33B5E5);
picker.setCancelTextSize(13);
picker.setSubmitTextColor(0xFF33B5E5);
picker.setSubmitTextSize(13);
picker.setSelectedTextColor(0xFFEE0000);
picker.setUnSelectedTextColor(0xFF999999);
LineConfig config = new LineConfig();
config.setColor(0xFFEE0000);//線顏色
config.setAlpha(140);//線透明度
config.setRatio((float) (1.0 / 8.0));//線比率
picker.setLineConfig(config);
picker.setItemWidth(200);
picker.setBackgroundColor(0xFFE1E1E1);
//picker.setSelectedItem(isChinese ? "處女座" : "Virgo");
picker.setSelectedIndex(7);
picker.setOnItemPickListener(new OnItemPickListener<String>() {
@Override
public void onItemPicked(int index, String item) {
showToast("index=" + index + ", item=" + item);
}
});
picker.show();
}