Android gallery里显示文字

有时候想 向左向右设置文字的变化 不妨试试gallery

Java代码   收藏代码
  1. "demo.xml"  
  2.   
  3. <?xml version="1.0" encoding="utf-8"?>  
  4. <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"  
  5. android:id="@+id/widget44"  
  6. android:layout_width="fill_parent"  
  7. android:layout_height="fill_parent"  
  8. android:orientation="vertical"  
  9. android:gravity="center_horizontal">  
  10.     <TextView  
  11.         android:id="@+id/txt1_gvi"  
  12.         android:layout_width="wrap_content"  
  13.         android:layout_height="wrap_content"  
  14.         android:textColor="#051b4d"  
  15.         android:gravity="center_horizontal"  
  16.         android:textColorHighlight="#656565"  
  17.         android:textSize="10sp">  
  18.     </TextView>  
  19. </LinearLayout>  

 

Java代码   收藏代码
  1. public Activity activity;  
  2.     private static LayoutInflater inflater=null;  
  3.     private String [] stringid=new String[]{"Index-Nifty","Positional calls","Intraday calls","InvestmentIdea","Optional calls","BTST-STBT calls"};       
  4.   
  5.     public TabGallary(Activity a) {       
  6.         activity = a;  
  7.         inflater =  (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
  8.     }  
  9.   
  10.     public int getCount(){  
  11.         return stringid.length;  
  12.     }     
  13.   
  14.     public Object getItem(int position) {  
  15.         return position;  
  16.     }  
  17.   
  18.     public long getItemId(int position) {  
  19.         return position;  
  20.     }  
  21.   
  22.     public View getView(int position, View convertView, ViewGroup parent)     
  23.     {             
  24.       View v;                       
  25.       if (convertView == null)   
  26.       {    
  27.            LayoutInflater li = getLayoutInflater();  
  28.            v = li.inflate(R.layout.demo, null);  
  29.            TextView tv1 = (TextView)v.findViewById(R.id.txt1_gvi);   
  30.            tv1.setText(stringid[position]);  
  31.            v.setOnClickListener(new OnClickListener()   
  32.            {                      
  33.                     @Override  
  34.                     public void onClick(View v)   
  35.                     {  
  36.                   // Call intent or perform ur activity;                  
  37.                     }  
  38.            });        
  39.       }  
  40.       else   
  41.       {  
  42.        v= convertView;  
  43.       }       
  44.   
  45.       return v;  
  46.    }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值