Java Code Examples for android.widget.GridView#setSelector()
The following examples show how to use
android.widget.GridView#setSelector() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmotionComplateFragment.java From timecat with Apache License 2.0 | 7 votes |
/** * 创建显示表情的GridView */ private GridView createEmotionGridView(List<String> emotionNames, int gvWidth, int padding, int itemWidth, int gvHeight) { // 创建GridView GridView gv = new GridView(getActivity()); //设置点击背景透明 gv.setSelector(android.R.color.transparent); //设置7列 gv.setNumColumns(7); gv.setPadding(padding, padding, padding, padding); gv.setHorizontalSpacing(padding); gv.setVerticalSpacing(padding * 2); //设置GridView的宽高 ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(gvWidth, gvHeight); gv.setLayoutParams(params); // 给GridView设置表情图片 EmotionGridViewAdapter adapter = new EmotionGridViewAdapter(getActivity(), emotionNames, itemWidth,emotion_map_type); gv.setAdapter(adapter); //设置全局点击事件 gv.setOnItemClickListener(GlobalOnItemClickManager.getInstance(getActivity()) .getOnItemClickListener(emotion_map_type)); return gv; }
Example 2
Source File: FourQuarterQuizView.java From android-topeka with Apache License 2.0 | 6 votes |
@Override protected View createQuizContentView() { mAnswerView = new GridView(getContext()); mAnswerView.setSelector(R.drawable.selector_button); mAnswerView.setNumColumns(2); mAnswerView.setAdapter(new OptionsQuizAdapter(getQuiz().getOptions(), R.layout.item_answer)); mAnswerView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { allowAnswer(); mAnswered = position; } }); return mAnswerView; }
Example 3
Source File: EmojiPageFragment.java From KJFrameForAndroid with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); sGrid = new GridView(getActivity()); sGrid.setNumColumns(KJEmojiConfig.COLUMNS); adapter = new EmojiGridAdapter(getActivity(), datas); sGrid.setAdapter(adapter); sGrid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EditText editText = (EditText) getActivity().findViewById( R.id.emoji_titile_input); if (position + 1 != datas.size()) { InputHelper.input(editText, (Emojicon) parent.getAdapter() .getItem(position)); } else { InputHelper.backspace(editText); } } }); sGrid.setSelector(new ColorDrawable(Color.TRANSPARENT)); return sGrid; }
Example 4
Source File: CityActivity.java From MyHearts with Apache License 2.0 | 6 votes |
@Override public void initView() { initData(); View view = View.inflate(this, R.layout.head_city_list, null); gridView = (GridView) view.findViewById(R.id.gridview_hot); gridViewAdapter = new CityGridViewAdapter(this, hotCity); gridView.setAdapter(gridViewAdapter); gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); sideBar = (SideBar) findViewById(R.id.sidrbar); dialog = (TextView) findViewById(R.id.dialog); sideBar.setTextView(dialog); sortListView = (ListView) findViewById(R.id.country_lvcountry); sortListView.addHeaderView(view); adapter = new SortAdapter(this, SourceDateList); sortListView.setAdapter(adapter); clearEditText = (ClearCityEditText) findViewById(R.id.filter_edit); }
Example 5
Source File: CalendarView.java From calendar with Apache License 2.0 | 6 votes |
private void initWeekGridView(Context context) { String[] from = new String[]{"week"}; int[] to = new int[]{R.id.tvWeekDay}; String[] strings = new String[]{ "日", "一", "二", "三", "四", "五", "六" }; List<Map<String, String>> weeks = new ArrayList<>(); for (String string : strings) { Map<String, String> map = new HashMap<>(); map.put(from[0], string); weeks.add(map); } ListAdapter adapter = new SimpleAdapter(context, weeks, R.layout.layout_week_view, from, to); GridView weekView = findViewById(R.id.weekView); weekView.setNumColumns(adapter.getCount()); weekView.setAdapter(adapter); weekView.setSelector(new ColorDrawable(Color.TRANSPARENT)); }
Example 6
Source File: ChatEmotionFragment.java From chatui with Apache License 2.0 | 6 votes |
/** * 创建显示表情的GridView */ private GridView createEmotionGridView(List<String> emotionNames, int gvWidth, int padding, int itemWidth, int gvHeight) { // 创建GridView GridView gv = new GridView(getActivity()); //设置点击背景透明 gv.setSelector(android.R.color.transparent); //设置7列 gv.setNumColumns(8); gv.setPadding(padding, padding, padding, padding); gv.setHorizontalSpacing(padding); gv.setVerticalSpacing(padding * 2); //设置GridView的宽高 ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(gvWidth, gvHeight); gv.setLayoutParams(params); // 给GridView设置表情图片 EmotionGridViewAdapter adapter = new EmotionGridViewAdapter(getActivity(), emotionNames, itemWidth); gv.setAdapter(adapter); //设置全局点击事件 gv.setOnItemClickListener(GlobalOnItemClickManagerUtils.getInstance(getActivity()).getOnItemClickListener()); return gv; }
Example 7
Source File: AlbumActivity.java From socialauth-android with MIT License | 5 votes |
/** * collection of grid properties */ @SuppressWarnings("static-access") public void getGridProperties(GridView view) { view.setNumColumns(3); view.setVerticalSpacing(5); view.setScrollBarStyle(view.SCROLLBARS_OUTSIDE_OVERLAY); view.setScrollingCacheEnabled(false); view.setGravity(Gravity.TOP); view.setSelector(new ColorDrawable(Color.parseColor("#00000000"))); view.setClipChildren(true); view.setPadding(5, 5, 5, 5); }
Example 8
Source File: EmoticonPageView.java From aurora-imui with MIT License | 5 votes |
public EmoticonPageView(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.item_emoticonpage, this); mGvEmotion = (GridView) view.findViewById(R.id.gv_emotion); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { mGvEmotion.setMotionEventSplittingEnabled(false); } mGvEmotion.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); mGvEmotion.setCacheColorHint(0); mGvEmotion.setSelector(new ColorDrawable(Color.TRANSPARENT)); mGvEmotion.setVerticalScrollBarEnabled(false); }
Example 9
Source File: WeekCalendar.java From WeekCalendar with Apache License 2.0 | 5 votes |
/** * 初始化日期 */ private GridView addDayView() { LayoutParams params = new LayoutParams( AbsListView.LayoutParams.FILL_PARENT, AbsListView.LayoutParams.WRAP_CONTENT); final GridView gridView = new GridView(context); gridView.setNumColumns(7); gridView.setGravity(Gravity.CENTER_VERTICAL); gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); gridView.setVerticalSpacing(1); gridView.setHorizontalSpacing(1); gridView.setLayoutParams(params); return gridView; }
Example 10
Source File: SubRecommendedFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sub_recommended, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_recommended_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) { parent.removeView(view); } sub_recommendedNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_recommended_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_recommended_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { sub_recommendedNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { sub_recommendedNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 11
Source File: SuperGridview.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override protected void initAbsListView(View v) { View listView = v.findViewById(android.R.id.list); if (listView instanceof GridView) mList = (GridView) listView; else throw new IllegalArgumentException(listView.getClass().getName()); if (mList!=null) { getList().setNumColumns(mColumns); getList().setVerticalSpacing(mVerticalSpacing); getList().setHorizontalSpacing(mHorizontalSpacing); getList().setHorizontalSpacing((int) mDividerHeight); getList().setVerticalSpacing((int) mDividerHeight); mList.setClipToPadding(mClipToPadding); mList.setOnScrollListener(this); if (mSelector != 0) mList.setSelector(mSelector); if (mPadding != -1.0f) { mList.setPadding(mPadding, mPadding, mPadding, mPadding); } else { mList.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom); } mList.setScrollBarStyle(mScrollbarStyle); } }
Example 12
Source File: SearchListActivity.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_searchlist); shuosou_to_tv = (TextView) findViewById(R.id.shuosou_to_tv); isFromRefreshData = true; recommendedGroups = new ArrayList<Group>(); mPullToRefreshView = (PullToRefreshView) findViewById(R.id.main_pull_refresh_view); mPullToRefreshView.setOnHeaderRefreshListener(this); mPullToRefreshView.setOnFooterRefreshListener(this); searchDetailRelativeLayout = (RelativeLayout) findViewById(R.id.searchdetail_relativeLayout); mPhotoWall = (GridView) findViewById(R.id.photo_wall); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); int status = NetworkStatus.networkStatus(); if (status == NetworkStatus.NETWORK_STATUS_REACHABLE) { this.showNoNetworkView(false); } else if (status == NetworkStatus.NETWORK_STATUS_NOTREACHABLE) { this.showNoNetworkView(true); } mPhotoWall.setOnItemClickListener(this); }
Example 13
Source File: SubLatestFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sub_latest, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_latest_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); subLatestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_latest_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_latest_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { subLatestNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { subLatestNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 14
Source File: SubRecommendedFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sub_recommended, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_recommended_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) { parent.removeView(view); } sub_recommendedNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_recommended_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_recommended_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { sub_recommendedNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { sub_recommendedNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 15
Source File: LatestFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_latest, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_latest_view); MainActivity activity = (MainActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); latestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.latest_netWork_relativeLayout); latestGridView = (GridView) view.findViewById(R.id.fragment_latest_gridview); latestGridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); latestGridView.setColumnWidth((int) width); latestGridView.setOnItemClickListener(this); if(this.mShowNoNetworkView){ latestNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); }else{ latestNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 16
Source File: RecommendedFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_recommended, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_recommended_view); MainActivity activity = (MainActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); mPhotoWall = (GridView) view.findViewById(R.id.fragment_recommended_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); recommendedNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.recommended_netWork_relativeLayout); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { recommendedNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { recommendedNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 17
Source File: SearchListActivity.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_searchlist); shuosou_to_tv = (TextView) findViewById(R.id.shuosou_to_tv); isFromRefreshData = true; recommendedGroups = new ArrayList<Group>(); mPullToRefreshView = (PullToRefreshView) findViewById(R.id.main_pull_refresh_view); mPullToRefreshView.setOnHeaderRefreshListener(this); mPullToRefreshView.setOnFooterRefreshListener(this); searchDetailRelativeLayout = (RelativeLayout) findViewById(R.id.searchdetail_relativeLayout); mPhotoWall = (GridView) findViewById(R.id.photo_wall); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); int status = NetworkStatus.networkStatus(); if (status == NetworkStatus.NETWORK_STATUS_REACHABLE) { this.showNoNetworkView(false); } else if (status == NetworkStatus.NETWORK_STATUS_NOTREACHABLE) { this.showNoNetworkView(true); } mPhotoWall.setOnItemClickListener(this); }
Example 18
Source File: SubLatestFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sub_latest, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_latest_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); subLatestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_latest_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_latest_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { subLatestNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { subLatestNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 19
Source File: TabMenu.java From coolreader with MIT License | 4 votes |
public TabMenu(Context context,OnItemClickListener titleClick,OnItemClickListener bodyClick, MenuTitleAdapter titleAdapter,int colorBgTabMenu,int aniTabMenu) { super(context); mLayout = new LinearLayout(context); mLayout.setOrientation(LinearLayout.VERTICAL); //标题选项栏 gvTitle = new GridView(context); gvTitle.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); gvTitle.setNumColumns(titleAdapter.getCount()); gvTitle.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); gvTitle.setVerticalSpacing(1); gvTitle.setHorizontalSpacing(1); gvTitle.setGravity(Gravity.CENTER); gvTitle.setOnItemClickListener(titleClick); gvTitle.setAdapter(titleAdapter); gvTitle.setSelector(new ColorDrawable(Color.TRANSPARENT));//选中的时候为透明色 this.titleAdapter=titleAdapter; //子选项栏 gvBody = new GridView(context); gvBody.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); gvBody.setSelector(new ColorDrawable(Color.TRANSPARENT));//选中的时候为透明色 gvBody.setNumColumns(4); gvBody.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); gvBody.setVerticalSpacing(10); gvBody.setHorizontalSpacing(10); gvBody.setPadding(5, 5, 5, 5); gvBody.setGravity(Gravity.CENTER); gvBody.setOnItemClickListener(bodyClick); mLayout.addView(gvTitle); mLayout.addView(gvBody); //设置默认项 this.setContentView(mLayout); this.setWidth(LayoutParams.FILL_PARENT); this.setHeight(LayoutParams.WRAP_CONTENT); this.setBackgroundDrawable(new ColorDrawable(colorBgTabMenu));// 设置TabMenu菜单背景 this.setAnimationStyle(aniTabMenu); this.setFocusable(true);// menu菜单获得焦点 如果没有获得焦点menu菜单中的控件事件无法响应 }
Example 20
Source File: ChatActivity.java From weixin with Apache License 2.0 | 4 votes |
/** * 设置笑脸被点击后的表情数据 */ private void setSmilingfaceData() { mV_myScrollView = new MyScrollView(this); mList_emoji = FaceConversionUtil.getInstace().emojiLists; // 添加表情页 mList_emojiAdapter = new ArrayList<EmojiAdapter>(); mV_myScrollView.removeAllViews(); for (int i = 0; i < mList_emoji.size(); i++) { // GridView的一些特殊属性: // // 1.android:numColumns=”auto_fit” //GridView的列数设置为自动 // 2.android:columnWidth=”90dp " //每列的宽度,也就是Item的宽度 // 3.android:stretchMode=”columnWidth"//缩放与列宽大小同步 // 4.android:verticalSpacing=”10dp” //两行之间的边距 // 5.android:horizontalSpacing=”10dp” //两列之间的边距 // 6.android:cacheColorHint="#00000000" //去除拖动时默认的黑色背景 // 7.android:listSelector="#00000000" //去除选中时的黄色底色 // 8.android:scrollbars="none" //隐藏GridView的滚动条 // 9.android:fadeScrollbars="true" //设置为true就可以实现滚动条的自动隐藏和显示 // 10.android:fastScrollEnabled="true" //GridView出现快速滚动的按钮(至少滚动4页才会显示) // 11.android:fadingEdge="none" //GridView衰落(褪去)边缘颜色为空,缺省值是vertical。(可以理解为上下边缘的提示色) // 12.android:fadingEdgeLength="10dip" //定义的衰落(褪去)边缘的长度 // 13.android:stackFromBottom="true" //设置为true时,你做好的列表就会显示你列表的最下面 // 14.android:transcriptMode="alwaysScroll" //当你动态添加数据时,列表将自动往下滚动最新的条目可以自动滚动到可视范围内 // 15.android:drawSelectorOnTop="false" //点击某条记录不放,颜色会在记录的后面成为背景色,内容的文字可见(缺省为false) // GridView view = new GridView(this); EmojiAdapter adapter = new EmojiAdapter(this, mList_emoji.get(i)); view.setAdapter(adapter); mList_emojiAdapter.add(adapter); view.setOnItemClickListener(this); view.setNumColumns(7); view.setBackgroundColor(Color.TRANSPARENT); // view.setHorizontalSpacing(1); //两列之间的边距 // view.setVerticalSpacing(10);//两行之间的边距 view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);//缩放与列宽大小同步 view.setCacheColorHint(0);//去除拖动时默认的黑色背景 // view.setPadding(5, 5, 5, 5); view.setSelector(new ColorDrawable(Color.TRANSPARENT)); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); view.setLayoutParams(params); view.setGravity(Gravity.CENTER); mV_myScrollView.addView(view); } mLl_chat_smilingface_body.removeAllViews(); mLl_chat_smilingface_body.addView(mV_myScrollView);//将MyScrollView添加到内容显示区 RadioGroup.LayoutParams params_rb = new RadioGroup.LayoutParams(DensityUtil.dip2px(this, 8), DensityUtil.dip2px(this, 8)); int marginValue = DensityUtil.dip2px(this, 3); params_rb.setMargins(marginValue, 0, marginValue, 0); for (int i = 0; i < mV_myScrollView.getChildCount(); i++) { RadioButton rbtn = new RadioButton(this); rbtn.setButtonDrawable(R.drawable.cgt_selector_chat_radiobtn_bg); rbtn.setId(i); mRg_chat_smilingface_tab.addView(rbtn, params_rb); if (i == 0) { rbtn.setChecked(true); } } /** * 监听单选按钮是否被选中, */ mRg_chat_smilingface_tab.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { current = checkedId; mV_myScrollView.moveToDest(checkedId); } }); /** * */ mV_myScrollView.setChangedListener(new IPageChangedListener() { @Override public void changedTo(int pageId) { current = pageId; ((RadioButton) mRg_chat_smilingface_tab.getChildAt(pageId)).setChecked(true); } }); }