Home | History | Annotate | Download | only in replicaisland
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 
     18 package com.replica.replicaisland;
     19 
     20 import android.content.Context;
     21 import android.view.Gravity;
     22 import android.view.LayoutInflater;
     23 import android.view.View;
     24 import android.widget.TextView;
     25 import android.widget.Toast;
     26 
     27 public class CustomToastSystem extends BaseObject {
     28 	private View mView;
     29 	private TextView mText;
     30 	private Toast mToast;
     31 
     32 	public CustomToastSystem(Context context) {
     33 		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     34 		mView = inflater.inflate(R.layout.custom_toast, null);
     35 
     36 		mText = (TextView) mView.findViewById(R.id.text);
     37 		mToast = new Toast(context);
     38 		mToast.setView(mView);
     39 
     40 	}
     41 
     42 
     43 	@Override
     44 	public void reset() {
     45 		// TODO Auto-generated method stub
     46 
     47 	}
     48 
     49 	public void toast(String text, int length) {
     50 		mText.setText(text);
     51 
     52 		mToast.setGravity(Gravity.CENTER, 0, 0);
     53 		mToast.setDuration(length);
     54 		mToast.show();
     55 	}
     56 
     57 }
     58