安卓 按钮不同状态开发,怎么去捕捉多个不同layout中的按钮

让LinearLayout的两个按钮之间有一些间隔
在LinearLayout中垂直布局两个按钮,想在两个按钮之间有一个间隔。不知道怎么实现,请帮忙。
布局文件如下:
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout
xmlns:android="/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:id="@+id/btnAction1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text = "HiText1"
android:id="@+id/btnAction2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text="HiText2"
android:layout_below="@id/btnAction1"
&/LinearLayout&
按赞数排序
试试下面的代码:
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout
xmlns:android="/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:id="@+id/btnAction1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text = "HiText1"
&Button android:layout_marginTop="50dp"
android:id="@+id/btnAction2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text="HiText2"
android:layout_below="@id/btnAction1"
&/LinearLayout&
其他相似问题
相关参考资料当前位置: >
> Android两个layout切换
Android两个layout切换
sdl111 & at
Android两个layout切换。
color.xml-----------------------  & xml version="1.0" encoding="utf-8" &
&resources&
&color name="black"&#000000&/color&
&color name="white"&#FFFFFFFF&/color&
&/resources&strings.xml-----------------------  & xml version="1.0" encoding="utf-8" &
&resources&
&string name="hello"&Hello World, Android_TowLayoutActivity!&/string&
&string name="app_name"&Android_TowLayout&/string&
&string name="layout1"&this is Layout 1&/string&
&string name="layout2"&This is Layout 2&/string&
&/resources&两个layout XMLstrings.xml----------------------  & xml version="1.0" encoding="utf-8" &
&LinearLayout xmlns:android=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/black"
android:orientation="vertical" &
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/layout1"
android:textSize="24sp" /&
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" /&
&/LinearLayout&mylayout.xml---------------------------------  & xml version="1.0" encoding="utf-8" &
&LinearLayout xmlns:android=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/black"
android:orientation="vertical" &
android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/layout2"
android:textSize="24sp" /&
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2" /&
&/LinearLayout&TowLayoutActivity.java-------------------------------------  package com.pandy.
import android.app.A
import android.os.B
import android.view.V
import android.view.View.OnClickL
import android.widget.B
import android.widget.TextV
public class TowLayoutActivity extends Activity {
/** Called when the activity is first created. */
private Button button1;
private Button button2;
private TextView text1;
private TextView text2;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
jumpLayout2();
//这里不能定义button2的的时间,否则会出错。但不知道什么原因,难道button2是R.layout.main的控件,才会出现这个情况?
button2 = (Button)findViewById(R.id.button2);
button2.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
jumpLayout1();
public void jumpLayout1() {
setContentView(R.layout.main);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
jumpLayout2();
public void jumpLayout2() {
setContentView(R.layout.mylayout);
button2 = (Button) findViewById(R.id.button2);
button2.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
jumpLayout1();
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&&&湘教QS2-164&&增值电信业务经营许可证湘B2-为什么在eclipse中新建安卓应用src、layout两个文件夹里没有东西_android开发吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:38,884贴子:
为什么在eclipse中新建安卓应用src、layout两个文件夹里没有东西收藏
为什么在eclipse中新建安卓应用src、layout两个文件夹里没有东西? 本人前几天用着还好好的,,今天突然建不出来文件了,请求大神给我一个权威的回复。网上找了很多方法,多数告诉我更新。可结果还是一样,请求各侠,如果谁遇到过这样的问题拜托告诉我一个解决方法可以嘛。。。。。。如果没有实战经验的朋友就不要乱回复了。。请遇到过这样的问题并解决的分享一下经验吧。。。
如果想有默认的东西,需要创建的最后一步,候选 创建默认Activity
没有就自己添加就好啦。
多谢你们的回复,不过你们的回答没什么用啊。。。。
这个现象我之前也出现过,最后是把SDK扩展更新完全,就好了。或者建立安卓项目的时候选择最低版本为安卓4.0以上。
登录百度帐号我的游戏推荐游戏
后查看最近玩过的游戏
为兴趣而生,贴吧更懂你。或16:32:35【 转载互联网】 作者: &&|&责编:李强
&&& &为了解决用户可能碰到关于"安卓开发 怎样可以点击按钮后在一个TextView显示不同的内容。 代码看着好好的,一点击就闪退"相关的问题,突袭网经过收集整理为用户提供相关的解决办法,请注意,解决办法仅供参考,不代表本网同意其意见,如有任何问题请与本网联系。"安卓开发 怎样可以点击按钮后在一个TextView显示不同的内容。 代码看着好好的,一点击就闪退"相关的详细问题如下:setText(&quot.
bt.setOnClickListener(this); TODO 自动生成的方法存根
tvpublic class MainActivity extends ActionBarActivity implements OnClickListener
{private BHello&
setContentView(R.tvs);
protected void onCreate(Bundle savedInstanceState) {
Button bt= (Button) findViewById(R;
TextView tv=(TextView) findViewById(R.onCreate(savedInstanceState).id.activity_main);&#47.button1);
} public void onClick(View v) {
/);private TextView tv===========突袭网收集的解决方案如下===========
解决方案1:t= (Button) findViewById(R; tv=(TextView) findViewById(R.button1).id.tvs).id解决方案2:  因为你的 tv 并没有初始化 , 所以会报错
================可能对您有帮助================
问:在eclipse软件中开发安卓软件时,现在在登陆界面有确定按钮,怎样实现点...答:Intent mainIntent = new Intent(appStartActivity.this,EntranceActivity.class); appStartActivity.this.startActivity(mainIntent); 按钮的onClickListener里面加入这个代码就好 不是直接复制哦,记得照着改===========================================问:在eclipse软件中开发安卓软件时,现在在登陆界面有确定按钮,怎样实现点...答:步骤总结一下: 1. 新建一个工程C 2. 双击主窗口 res-&layout-&activety_main.xml 前面的小图标, 出现Graphical Layout可视化界面,拖上 控件 button,并修改对象名称,这有点类似于可视化IDE; 控件对象的初始参数就在资源中; 3. 手工添...===========================================问:点击按钮,弹出对话框,如图所示, 要求输入密码信息,在对密码信息进行...答:在button事件里面,弹出一个AlertDialog。如果密码正确,则在这个AlertDialog的确定按钮的点击事件里面打开一个新的activity,用来显示你预设的网页;如果密码不正确,则用这个AlertDialog来提示密码不正确,则只提示不正确,不打开新的activity...===========================================问:点击一个report 出来 一长串的按钮答:public void showSetPopupWindow() { if (popupWindow != null && popupWindow.isShowing()) { popupWindow.dismiss(); } ListView listView = (ListView) mContext.getLayoutInflater().inflate( R.layout.listview, null); MenuItemAdapter se...===========================================问:为此,我在src文件下新建了一个GraphicsView.java文件,实现GraphicsVie...答:publicclassMainActivity extendsActivity { @Override protectedvoidonCreate(Bundle savedInstanceState) { ....... Button button =(Button)this.findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener(){//点击该...===========================================问:就是我创建一个按钮和一个edittext 。按钮想往edittext输入值,但是每次...答:你不是很容易吗 例如 EditText et=(EditText)findViewById(R.id.et);//初始化控件Button btn1=(Button)findViewById(R.id.btn1);Button btn2=(Button)findViewById(R.id.btn1); ed.setInputType(InputType.TYPE_NULL);//不呼出软键盘 btn1.setOn...===========================================问:想实现点击一个图片按钮 旋转一圈 360度 然后再接着走监听事件答:final RotateAnimation animation = new RotateAnimation(0, 360);animation.setDuration(3000);final ImageView imageView = (ImageView) findViewById(R.id.myimageview);animation.setAnimationListener(new AnimationListener() {@Overridep...===========================================问:安卓开发问题,页面上只有一个按钮,我要点击按钮显示一个toast,但是点...答:在开发者模式中有选项可以开启是否显示系统提示的选项,如果是否则不会显示Toast===========================================问:有一个textview和按钮,textview如何显示按钮的点击次数?求完整代码,...答:public class MainActivity extends Activity { /**显示点击数量*/ private TextV /**点击按钮*/ private B /**计数*/ private int count = 0; private Handler handler = new Handler(){ @Override public void handleMe...===========================================

我要回帖

更多关于 安卓开关按钮 的文章

 

随机推荐