//titlebar 内容        public NewsVideo()          {            String[] arrayOfString1 = new String[7];            arrayOfString1[0] = "推荐";            arrayOfString1[1] = "电视剧";            arrayOfString1[2] = "电影";            arrayOfString1[3] = "纪录片";            arrayOfString1[4] = "动画片";            arrayOfString1[5] = "综艺";            arrayOfString1[6] = "新闻";            this.strLblTile = arrayOfString1;            this.currentTitlePosition = 0;            this.oldTitlePosition = currentTitlePosition;          }//动态加载titleBar        LayoutInflater inflater= LayoutInflater.from(this);;        View view = inflater.inflate(R.layout.titlebar, null);        RelativeLayout localRelativeLayout2 = (RelativeLayout)this.findViewById(R.id.titleBar);        localRelativeLayout2.addView(view);//初始化titleBar        NewsVideo nv= new NewsVideo();        linearLayTitle=(LinearLayout) this.findViewById(R.id.linearLayTitle);        initTitleBar();//private void initTitleBar()   {     TextView[] arrayOfTextView1 = new TextView[this.strLblTile.length];     this.lblArr = arrayOfTextView1;     Resources localResources = getResources();     for (int i = 0; ; ++i)     {       int j = this.lblArr.length;       if (i >= j)       {         TextView[] arrayOfTextView2 = this.lblArr;         int k = this.currentTitlePosition;         arrayOfTextView2[k].setTextColor(-1);         TextView[] arrayOfTextView3 = this.lblArr;         int l = this.currentTitlePosition;         arrayOfTextView3[l].setBackgroundResource(R.drawable.nav_light);         return;       }              TextView[] arrayOfTextView4 = this.lblArr;       TextView localTextView1 = new TextView(this);       arrayOfTextView4[i] = localTextView1;       TextView localTextView2 = this.lblArr[i];       int i1 = Mconst.screenwidth * 67 / 320;       ///System.out.println("i1  "+i1);       localTextView2.setWidth(i1);       TextView localTextView3 = this.lblArr[i];       int i2 = Mconst.screenheight * 40 / 480;       localTextView3.setHeight(i2);       //System.out.println("i2  "+i2);       this.lblArr[i].setTextSize(14);       this.lblArr[i].setGravity(17);       TextView localTextView4 = this.lblArr[i];       String str = this.strLblTile[i];       localTextView4.setText(str);       TextView localTextView5 = this.lblArr[i];       int i3 = localResources.getColor(R.color.white);       localTextView5.setTextColor(i3);       LinearLayout localLinearLayout = this.linearLayTitle;       TextView localTextView6 = this.lblArr[i];       //System.out.println("第"+i+"个"+lblArr[i].getText());       localLinearLayout.addView(localTextView6);       int i4 = i;       TextView localTextView7 = this.lblArr[i4];       localTextView7.setOnClickListener(new TitleBarListener(this,i4));     }   }       class TitleBarListener implements View.OnClickListener{                      int i;           Context con;        public TitleBarListener(NewsVideo newsVideo, int i4) {                // TODO Auto-generated constructor stub                con=newsVideo;                this.i=i4;        }        @Override        public void onClick(View v) {                // TODO Auto-generated method stub                currentTitlePosition=i;                if(currentTitlePosition!=oldTitlePosition){                        lblArr[oldTitlePosition].setBackgroundDrawable(null);                        oldTitlePosition=currentTitlePosition;                        lblArr[currentTitlePosition].setBackgroundResource(R.drawable.nav_light);                }                switch(currentTitlePosition){                case 0:                case 1:                case 2:                case 3:                case 4:                case 5:                case 6:                        Toast.makeText(con, "您正在浏览 "+lblArr[currentTitlePosition].getText()+" 页面", Toast.LENGTH_SHORT).show();                        break;                default:                        break;                }         }   } 



更多相关文章

  1. Sqlite3 增删改查操作实例
  2. Android(安卓)MediaPlayer播放prepareAsync called in state 8解
  3. 修正android 处理连续按键两次
  4. android IApplicationToken分析
  5. android音乐播放器(4)
  6. android通过NFC读取卡号
  7. Android四大图片缓存框架之-Fresco之initialize(二)
  8. Android(安卓)备忘录
  9. Android属性动画源代码解析(超详细)

随机推荐

  1. android 动画详解(收藏)
  2. 【Android界面实现】Starting an Activit
  3. Android一 流
  4. AndroidStudio3.0及以上 使用第三方注解
  5. Android开发常用开源框架2
  6. Android(安卓)Studio升级到3.1出现的变化
  7. Android之位置的服务
  8. Android(安卓)监听软键盘状态
  9. 在代码中设置RelativeLayout布局中标签的
  10. 解决:Error: Could not find gradle wrapp