未命名  

package com.fec.newLayout;


import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

public class newLayout_Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.main);
        setContentView(R.layout.main);

 
        
        showViewToast() ;


    }
    
    public void showViewToast() {
        LayoutInflater inflater = getLayoutInflater();
        View toastLayout = inflater.inflate(R.layout.toast_pic,(ViewGroup)findViewById(R.id.toast_pic));
                Toast toast = new Toast(this);
        
        toast.setGravity(Gravity.CENTER, 0, 0);
        
        toast.setDuration(Toast.LENGTH_LONG);
        
        toast.setView(toastLayout);
        
        toast.show();
    }
}

 

 

程式碼下載

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()