// 返回每一组的textview @Override public View getView(int group, int position, View convertView) { TextView txtKeyword; if (convertView instanceof TextView) { txtKeyword = (TextView) convertView; } else { txtKeyword = new TextView(UIUtils.getContext()); } // 数据分了2组,第一组就是0-14,每一组是15个数据 final String keyword = mDatas.get(group * 15 + position); // 随机颜色的范围0x202020~0xefefef int red = 30 + mRdm.nextInt(208); int green = 32 + mRdm.nextInt(208); int blue = 32 + mRdm.nextInt(208); // int color = 0xff000000 | (red << 16) | (green << 8) | blue; int color = Color.rgb(red, green, blue); txtKeyword.setTextColor(color); txtKeyword.setTextSize(16 + mRdm.nextInt(6)); txtKeyword.setText(keyword); txtKeyword.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { UIUtils.showToastSafe( UIUtils.getString(R.string.recommend_toast) + ((TextView) v).getText()); } }); return txtKeyword; }
@Override protected View createLoadedView() { mStellarMap = new StellarMap(UIUtils.getContext()); // 设置pading值 mStellarMap.setInnerPadding(20, 20, 20, 20); // 横向和纵向有几行几列 mStellarMap.setRegularity(6, 9); mStellarMap.setAdapter(new StellarMapAdapter()); mShakeListener = new ShakeListener(UIUtils.getContext()); mShakeListener.setOnShakeListener( new ShakeListener.OnShakeListener() { @Override public void onShake() { int currentGroup = mStellarMap.getCurrentGroup(); mStellarMap.setGroup((currentGroup + 1) % 2, true); } }); // 第一个参数是从0组开始,第二个参数是否开启动画 mStellarMap.setGroup(0, true); mStellarMap.setBackgroundResource(R.drawable.grid_item_bg_normal); return mStellarMap; }