我的include和activity的使用
来源:互联网 发布:有淘宝店铺就能贷款吗? 编辑:程序博客网 时间:2024/05/22 09:39
** * Activity基类 * * @author zy * */public class BaseActivity extends Activity { private Handler handler = new Handler(Looper.getMainLooper()); private ImageView leftIe; private ImageView rightIe; private TextView midIe; private ProgressDialog waitDialog; private AlertDialog take_phone_dlg;//call_dialog @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); take_phone_dlg = new AlertDialog.Builder(this).create(); } @Override protected void onResume() { super.onResume(); initTopLayout(this); setTop(leftIe,rightIe); // showToast("baseActivity,--->onResume"); } /** *@author ace *对bar按钮操作和显示 */ private void setTop(ImageView leftIe, ImageView rightIe) { //返回按钮 leftIe.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { onBackPressed(); } }); //电话按钮 rightIe.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { showCallPhoneDlg("取消","确定"); } }); } /** * *@author ace *加载include布局 */ private void initTopLayout(BaseActivity bat) { LinearLayout layout = (LinearLayout) bat.findViewById(R.id.include_titleBar); if (layout==null){ throw new RuntimeException("please inlucde layout common_title in Ur layout,and make sure the include id is @+id/include_titleBar"); } this.leftIe= (ImageView) layout.findViewById(R.id.include_back_button); this.rightIe= (ImageView) layout.findViewById(R.id.include_phone_button); this.midIe= (TextView) layout.findViewById(R.id.include_header_content); } /** * 设置标题 */ public void setTitle(String text) { ((TextView) findViewById(R.id.include_header_content)).setText(text); } /** * 设置标题 */ public void setTitle(int resId) { setTitle(getResources().getString(resId)); } @Override public void onBackPressed() { setResult(RESULT_OK, new Intent()); super.onBackPressed(); } /** *打电话 *@author ace */ private void showCallPhoneDlg(String cancle, String sure) { take_phone_dlg.show(); String title = "确认拨打电话: 400-181-0011 吗?"; take_phone_dlg.getWindow().setContentView(R.layout.dialog_photo_source); ((TextView) (take_phone_dlg.getWindow().findViewById(R.id.photo_source_info))).setText(title); ((TextView) (take_phone_dlg.getWindow().findViewById(R.id.photo_source_taking_picture))).setText(cancle); ((TextView) (take_phone_dlg.getWindow().findViewById(R.id.photo_source_photo_graph))).setText(sure); take_phone_dlg.getWindow().findViewById(R.id.photo_source_taking_picture).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { take_phone_dlg.dismiss(); } });//灰 take_phone_dlg.getWindow().findViewById(R.id.photo_source_photo_graph).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { take_phone_dlg.show(); Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:4001810011")); if (ActivityCompat.checkSelfPermission(getApplication(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } startActivity(intent); take_phone_dlg.dismiss(); } }); }//蓝 protected String getTextString(int resId) { return ((TextView) findViewById(resId)).getText().toString(); } protected void setTextString(int resId, String text) { ((TextView) findViewById(resId)).setText(text); } public void showToast(final String message) { handler.post(new Runnable() { @Override public void run() { Toast.makeText(BaseActivity.this, message, Toast.LENGTH_LONG).show(); } }); } public boolean isWaitDialogShow(){ return waitDialog.isShowing(); } public void showWaitDialog(String text) { waitDialog.setMessage(text); waitDialog.show(); } public void showWaitDialog() { if(isWaitDialogShow()){ return; } waitDialog.setMessage(getString(R.string.loading)); waitDialog.show(); } public void dismissWaitDialog() { if(isWaitDialogShow()){ waitDialog.dismiss(); } }}
0 0
- 我的include和activity的使用
- include 和include 的区别
- #include"" 和#include的区别
- #include ""和 #include 的区别
- #include 和 #include "" 的区别
- include 和 include "" 的区别
- #include “”和#include 的区别
- #include< >和#include””的区别
- #include< >和#include“ ”的区别
- #include<>和#include “”的区别
- #include""和#include<>的区别
- #include "" 和include<>的用法
- #include< >和#include“ ”的区别
- #include< >和#include“ ”的区别
- #include和#include“”的区别
- #include<> 和#include“”的区别
- include""和include<>的区别
- #include<> 和 #include""的区别
- kmp算法中next[]数组求法的基本思想
- 使用Spring3.2.0+Hibernate3.2.2+Struts2 2.2.3整合小demo以及配置使用的jar包集合
- Spring整合JMS(一)——基于ActiveMQ实现
- C# IQueryable和IEnumerable的区别
- Same Tree
- 我的include和activity的使用
- js 字符串 replace replaceAll
- 7.2 ipu_device.c分析(二)---具体函数分析
- 极光推送使用方法介绍
- win装vim
- oracle 导入数据泵数据库 (表空间创建、授权等)
- 实模式和保护模式区别及寻址方式
- 线程调度四(setDaemon方法的使用)
- A Simple Nim