2013年1月14日 星期一

gallery 显示文字

有时候想 向左向右设置文字的变化 不妨试试gallery
  • <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"  
  • android:id="@+id/widget44"  
  • android:layout_width="fill_parent"  
  • android:layout_height="fill_parent"  
  • android:orientation="vertical"  
  • android:gravity="center_horizontal">   
  •     <TextView   
  •         android:id="@+id/txt1_gvi"  
  •         android:layout_width="wrap_content"  
  •         android:layout_height="wrap_content"  
  •         android:textColor="#051b4d"  
  •         android:gravity="center_horizontal"  
  •         android:textColorHighlight="#656565"  
  •         android:textSize="10sp">   
  •     </TextView>   
  • </LinearLayout>  


    1. public Activity activity;   
    2.     private static LayoutInflater inflater=null;   
  •     private String [] stringid=new String[]{"Index-Nifty","Positional calls","Intraday calls","InvestmentIdea","Optional calls","BTST-STBT calls"};        
  •   
  •     public TabGallary(Activity a) {        
  •         activity = a;   
  •         inflater =  (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);   
  •     }   
  •   
  •     public int getCount(){   
  •         return stringid.length;   
  •     }      
  •   
  •     public Object getItem(int position) {   
  •         return position;   
  •     }   
  •   
  •     public long getItemId(int position) {   
  •         return position;   
  •     }   
  •   
  •     public View getView(int position, View convertView, ViewGroup parent)      
  •     {              
  •       View v;                        
  •       if (convertView == null)    
  •       {     
  •            LayoutInflater li = getLayoutInflater();   
  •            v = li.inflate(R.layout.demo, null);   
  •            TextView tv1 = (TextView)v.findViewById(R.id.txt1_gvi);    
  •            tv1.setText(stringid[position]);   
  •            v.setOnClickListener(new OnClickListener()    
  •            {                       
  •                     @Override  
  •                     public void onClick(View v)    
  •                     {   
  •                   // Call intent or perform ur activity;                   
  •                     }   
  •            });         
  •       }   
  •       else    
  •       {   
  •        v= convertView;   
  •       }        
  •   
  •       return v;   
  •    }  
  • 沒有留言:

    張貼留言