android脚步---UI界面修改,增加按钮和监听
我的UU界面,其布局如下:

需要修改的部分:

意见反馈居中,还有增加backbutton
首先在mainactivity中找到我的UU的定义:dialogue
public void showAboutDialog() {
if(mAboutDialog == null) {
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View aboutView = inflater.inflate(R.layout.aboutuu_layout, null, false);
Button backBnt = (Button)aboutView.findViewById(R.id.backbutton);
backBnt.setOnClickListener(mViewClickListener);
TextView versionTxt = (TextView)aboutView.findViewById(R.id.versiontext);
RelativeLayout versionCheckLayout = (RelativeLayout)aboutView.findViewById(R.id.checkversion);
versionCheckLayout.setOnClickListener(mViewClickListener);
RelativeLayout frameCheckLayout = (RelativeLayout)aboutView.findViewById(R.id.checkframe);
frameCheckLayout.setOnClickListener(mViewClickListener);
// RelativeLayout focusWbLayout = (RelativeLayout)aboutView.findViewById(R.id.focusweibo);
// focusWbLayout.setOnClickListener(mViewClickListener);
// RelativeLayout focusWxLayout = (RelativeLayout)aboutView.findViewById(R.id.focusweixin);
// focusWxLayout.setOnClickListener(mViewClickListener);
RelativeLayout marketScore = (RelativeLayout)aboutView.findViewById(R.id.toscore);
marketScore.setOnClickListener(mViewClickListener);
RelativeLayout contactsLayout = (RelativeLayout)aboutView.findViewById(R.id.contactus);
contactsLayout.setOnClickListener(mViewClickListener);
RelativeLayout fansLayout = (RelativeLayout)aboutView.findViewById(R.id.introtomyfriend);
fansLayout.setOnClickListener(mViewClickListener);
if(isNeedAd == true) {
RelativeLayout rl_ad= (RelativeLayout)aboutView.findViewById(R.id.rl_ad);
banner=new DiandeBanner(this,banner_AD_ID);
if(banner != null) {
// rl_ad=(RelativeLayout)findViewById(R.id.rl_ad);
rl_ad.addView(banner);
banner.show();
}
}
根据R.layout找到各个对应的xml文件
,意见反馈对应的是contactus.进入它的监听中,监听按键找到它的xml入口。
OnClickListener mViewClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.checkversion:
UpdateManager manager = new UpdateManager(CameraActivity.this);
if (manager.isNetworkConnected()) {
manager.checkUpdate();
} else {
manager.showNetworkDialog();
}
break;
case R.id.toscore:
Uri uri = Uri.parse("market://details?id="+getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(intent);
}catch(ActivityNotFoundException e) {
CustomToast.showToast(CameraActivity.this, R.string.toast_appmarket_not_installed, Toast.LENGTH_SHORT);
}
break;
case R.id.checkframe:
if (mCurrentModule instanceof PhotoModule) {
PhotoUI ui = ((PhotoModule) mCurrentModule).getPhotoUIInstance();
if (ui != null) {
PhotoFrameUpdateManager photoFrameManager =
new PhotoFrameUpdateManager(CameraActivity.this, ui);
if (photoFrameManager.isNetworkConnected()) {
// photoFrameManager.checkUpdate();
startActivityForResult(new Intent(CameraActivity.this, KuangDownloadActivity.class), REQ_CODE_DOWNLOAD);
} else {
photoFrameManager.showNetworkDialog();
}
}
}
break;
case R.id.contact_weibo:
followWB();
break;
case R.id.contact_weixin:
showFollowWxDialog();
break;
case R.id.contactus:
showContactsFunc();
break;
case R.id.contact_fans:
showFansforumPage();
break;
case R.id.introtomyfriend:
Intent recIntent = new Intent(Intent.ACTION_SEND);
recIntent.setType("text/plain");
recIntent.putExtra(Intent.EXTRA_TEXT, CameraActivity
.this.getString(R.string.rec_app_msg)+Constants.UU_LINK_URI);
startActivity(recIntent);
break;
case R.id.backbutton:
if(mAboutDialog != null) {
mAboutDialog.dismiss();
mAboutDialog = null;
}
break;
case R.id.backbutton1:
if(mFeedBackDialog != null) {
mFeedBackDialog.dismiss();
mFeedBackDialog = null;
}
break;
}
}
};
找到R.id.contact_weibo,点击进入xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff" > <RelativeLayout
android:id="@+id/title"
android:layout_height="@dimen/about_title_height"
android:layout_width="match_parent"
android:background="@color/aboutuu_title"
>
<TextView
android:id="@+id/title_text"
android:layout_width="match_parent"
android:layout_height="@dimen/about_title_height"
android:gravity="center"
android:text="@string/contact_us"
android:textColor="#ffffff"
android:textSize="@dimen/about_title_text_size"
android:background="@color/aboutuu_title"
android:paddingLeft="@dimen/about_title_btn_margin_left"/> <Button
android:id="@+id/backbutton1"
android:layout_width="@dimen/about_title_height"
android:layout_height="@dimen/about_title_height"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/about_title_btn_margin_left"
android:background="@drawable/about_back" />
</RelativeLayout>
将其 android:gravity="center"变成居中,还有增加Button,因为增加Button后提示android:layout_centerVertical="true"应用于相对布局,所以将线性布局改成相对布局。布局文件修改iwanbi后在JAVA文件中增加监听:
if(mFeedBackDialog == null) {
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View fbView = inflater.inflate(R.layout.feedback_layout, null, false);
Button backBn = (Button)fbView.findViewById(R.id.backbutton1);
backBn.setOnClickListener(mViewClickListener);
利用inflater引入布局文件,定义按钮,引用公共监听类,公共监听类中增加按钮backbutton1.
android脚步---UI界面修改,增加按钮和监听的更多相关文章
- android脚步---UI界面修改,关于activity中增加按钮和监听
增加按钮和监听,这个和上个不同在于,它不是在一个dialog里面,而是从新写了一个activity,因此需要先找到这个activity的入口. case R.id.checkframe: if (mC ...
- Android 给按钮添加监听事件
在安卓开发中,如果要给一个按钮添加监听事件的话,有以下三种实现方式 1.方式一 public class MainActivity extends ActionBarActivity { @Overr ...
- Android软键盘的隐藏显示、事件监听的代码
把开发过程中重要的一些内容片段做个珍藏,如下资料是关于Android软键盘的隐藏显示.事件监听的内容,应该是对小伙伴们有所用途. public class ResizeLayout extends L ...
- IOS第五天(1:取消按钮的监听和设置代理textField字数限制)
***********取消按钮的监听和设置代理textField字数限制 UITextFieldDelegate #import "HMViewController.h" @int ...
- Android开发之手势滑动(滑动手势监听)详解
Android开发之手势滑动(滑动手势监听)详解 在Android应用中,经常需要手势滑动操作,比如上下滑动,或左右方向滑动,处理手势滑动通常有两种方法:一种是单独实现setOnTouchListen ...
- android CheckBox控件的定义及事件监听
http://www.beijibear.com/index.php?aid=336 android CheckBox控件的定义及事件监听,本例实现CheckBox控件的定义及点击事件的监听并显示结果 ...
- Android TV开发中所有的遥控器按键监听及注意事项,新增home键监听
原文:Android TV开发中所有的遥控器按键监听及注意事项,新增home键监听 简单记录下android 盒子开发遥控器的监听 ,希望能帮到新入门的朋友们 不多说,直接贴代码 public cla ...
- Android——控制UI界面
一.使用XML布局文件控制UI界面 res\layout\activity_main.xml代码如下: <FrameLayout xmlns:android="http://schem ...
- Android控制UI界面
⒈使用XML布局文件控制UI界面[推荐] Android推荐使用XML布局文件来控制视图,这样不仅简单.明了,而且可以将应用的视图控制逻辑从Java或Kotlin代码中分离出来,放入XML文件中控制, ...
随机推荐
- Android PagerAdapter的用法
转http://blog.csdn.net/look85/article/details/8563906 在写这个之前,真心需要吐槽一下…关于Android开发中,PageAdapter的用法在网上能 ...
- 在Activity之间传递数据—获取Activity返回的数据
在获取返回值时要注意的是打开Activity的方式,用方法:startActivityForResult 接收时,重写方法:onActivityResult 在子Activity中,写数据用方法:se ...
- Linux文件系统的目录结构
Linux下的文件系统为树形结构,入口为/ 树形结构下的文件目录: 无论哪个版本的Linux系统,都有这些目录,这些目录应该是标准的.各个Linux发行版本会存在一些小小的差异,但总体来说,还是大体差 ...
- HDU 4857 逃生(反向拓扑排序+优先队列)
( ̄▽ ̄)" //这题对序号输出有要求,较小的序号优先输出,所以用到优先队列 //优先队列是优先弹出值最大的,所以最后要反向输出结果,才是正确的output #include<iost ...
- hdu_4718_The LCIS on the Tree(树链剖分+线段树合并)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4718 题意:给你一棵树,每个节点有一个值,然后任给树上的两点,问这两点的最长连续递增区间是多少 题解: ...
- hdu_1728_逃离迷宫(bfs)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1728 题意:走迷宫,找最小的拐角 题解:对BFS有了新的理解,DFS+剪枝应该也能过,用BFS就要以拐 ...
- hdu_4826_Labyrinth_2014百度之星(dp)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 题意:中文题,不解释 题解:dp搞,第一列只能从上往下走,所以先算出第一列的dp数组,然后开两个 ...
- 在 Visual Studio 2010 中创建 SharePoint 2010 事件接收器
Microsoft Visual Studio 2010 提供了一个可用于生成事件接收器的项目类型,事件接收器会在 Microsoft SharePoint 2010 网站上选择事件之前或之后执行操作 ...
- AngularJS 的表单验证
最近开始学习angularjs,学到表单验证的时候发现有必要学习下大神的好文章: 转:http://www.oschina.net/translate/angularjs-form-validatio ...
- PHP详解$_SEVER常用变量
$_SERVER['HTTP_ACCEPT_LANGUAGE']//浏览器语言 $_SERVER['HTTP_ACCEPT'] //当前请求的Accept头部的内容,例如text/html,appli ...