首页 > 移动平台 > 详细

android 入门-Activity及 字体

时间:2014-12-10 19:36:12      阅读:316      评论:0      收藏:0      [点我收藏+]

 

    private Button sButton;
    private TextView mTextView;
    private Button fButton;
    private int[] sArray={13,25,38,34,42};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ex0313);
        
        mTextView=(TextView)findViewById(id.Ex0313DisplayText);
        sButton=(Button)findViewById(id.Ex0313SizeButton);
        sButton.setOnClickListener(new Button.OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                
                Random mRandom=new Random();
                int mNum = mRandom.nextInt(4);
                mTextView.setTextSize(sArray[mNum]);
            }
        });        
        
        fButton=(Button)findViewById(id.Ex0313FontsButton);
        fButton.setOnClickListener(new Button.OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Typeface fTypeface=Typeface.createFromAsset(getResources().getAssets(),"fonts/PentaGram‘sMalefissent.ttf");
                mTextView.setTypeface(fTypeface);
            }
        });                
    }

bubuko.com,布布扣bubuko.com,布布扣

     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/Ex0313DisplayText"
     android:layout_marginLeft="20dp"
        android:layout_marginTop="10dp"        
        android:text="@string/hello_world" />
<Button android:id="@+id/Ex0313SizeButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="50dp"
        android:text="@string/ex0313sizebutton" />
<Button android:id="@+id/Ex0313FontsButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="100dp"
        android:text="@string/ex0313fontsbutton" />

 

android 入门-Activity及 字体

原文:http://www.cnblogs.com/luquanmingren/p/4156137.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!