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 18package com.replica.replicaisland; 19 20import android.content.Context; 21import android.view.Gravity; 22import android.view.LayoutInflater; 23import android.view.View; 24import android.widget.TextView; 25import android.widget.Toast; 26 27public 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