我无法点击按钮。我以前做过这个,但这次我不知道为什么它不起作用。 Scrollview工作正常,但没有点击按钮。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Black" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttoneez1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/yeah23"
android:text="TNT"
android:textColor="@color/White" />
<Button
android:id="@+id/buttoneez2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/buttoneez1"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="HIGH VOLTAGE"/>
<Button
android:id="@+id/buttoneez3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez2"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="LET THERE BE ROCK" />
<Button
android:id="@+id/buttoneez4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez3"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="POWERAGE" />
<Button
android:id="@+id/buttoneez5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez4"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="IF U WANT BLOOD" />
<Button
android:id="@+id/buttoneez6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez5"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="BACK IN BLACK" />
<Button
android:id="@+id/buttoneez7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez6"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="DIRTY DEEDS DONE CHEAP"/>
<Button
android:id="@+id/buttoneez8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez7"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="FOR THOSE ABOUT TO ROCK" />
<Button
android:id="@+id/buttoneez9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez8"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="FLICK OF THE SWITCH"/>
<Button
android:id="@+id/buttoneez10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez9"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="JAILBREAK" />
<Button
android:id="@+id/buttoneez11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez10"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="FLY ON THE WALL" />
<Button
android:id="@+id/buttoneez12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/buttoneez11"
android:background="@drawable/yeah23"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:textColor="@color/White"
android:text="WHO MADE WHO" />
<Button
android:id="@+id/buttoneez13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez12"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="BLOW UP YOUR VIDEO" />
<Button
android:id="@+id/buttoneez14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez13"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="THE RAZORS EDGE" />
<Button
android:id="@+id/buttoneez15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez14"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="HIGHWAY TO HELL" />
<Button
android:id="@+id/buttoneez16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez15"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="BALLBREAKER" />
<Button
android:id="@+id/buttoneez17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez16"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="BLACK ICE" />
<Button
android:id="@+id/buttoneez18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez17"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:text="THE RAZORS EDGE" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
这是我的java类
package com.surajmal.rocklegends2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Acdc extends Activity implements OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.acdc);
Button button1 = (Button) findViewById(R.id.buttoneez1);
Button button2 = (Button) findViewById(R.id.buttoneez2);
Button button3 = (Button) findViewById(R.id.buttoneez3);
Button button4 = (Button) findViewById(R.id.buttoneez4);
Button button5 = (Button) findViewById(R.id.buttoneez5);
Button button6 = (Button) findViewById(R.id.buttoneez6);
Button button7 = (Button) findViewById(R.id.buttoneez7);
Button button8 = (Button) findViewById(R.id.buttoneez8);
Button button9 = (Button) findViewById(R.id.buttoneez9);
Button button10 = (Button) findViewById(R.id.buttoneez10);
Button button11 = (Button) findViewById(R.id.buttoneez11);
Button button12 = (Button) findViewById(R.id.buttoneez12);
Button button13 = (Button) findViewById(R.id.buttoneez13);
Button button14 = (Button) findViewById(R.id.buttoneez14);
Button button15 = (Button) findViewById(R.id.buttoneez15);
Button button16 = (Button) findViewById(R.id.buttoneez16);
Button button17 = (Button) findViewById(R.id.buttoneez17);
Button button18 = (Button) findViewById(R.id.buttoneez18);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);
button4.setOnClickListener(this);
button5.setOnClickListener(this);
button6.setOnClickListener(this);
button7.setOnClickListener(this);
button8.setOnClickListener(this);
button9.setOnClickListener(this);
button10.setOnClickListener(this);
button11.setOnClickListener(this);
button12.setOnClickListener(this);
button13.setOnClickListener(this);
button14.setOnClickListener(this);
button15.setOnClickListener(this);
button16.setOnClickListener(this);
button17.setOnClickListener(this);
button18.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.buttoneez1:
String namaste = "1";
Intent dex = new Intent(Acdc.this, Acdctwo.class);
dex.putExtra("url", 1);
startActivity(dex);
finish();
break;
case R.id.buttoneez2:
String a = "2";
Intent q = new Intent(Acdc.this, Acdctwo.class);
q.putExtra("url", 2);
startActivity(q);
break;
case R.id.buttoneez3:
String b = "3";
Intent w = new Intent(Acdc.this, Acdctwo.class);
w.putExtra("url", 3);
startActivity(w);
break;
case R.id.buttoneez4:
String c = "4";
Intent e = new Intent(Acdc.this, Acdctwo.class);
e.putExtra("url", 4);
startActivity(e);
break;
case R.id.buttoneez5:
String d = "5";
Intent r = new Intent(Acdc.this, Acdctwo.class);
r.putExtra("url", 5);
startActivity(r);
break;
case R.id.buttoneez6:
String f = "6";
Intent t = new Intent(Acdc.this, Acdctwo.class);
t.putExtra("url", 6);
startActivity(t);
break;
case R.id.buttoneez7:
String g = "7";
Intent y = new Intent(Acdc.this, Acdctwo.class);
y.putExtra("url", 7);
startActivity(y);
break;
case R.id.buttoneez8:
String h = "8";
Intent u = new Intent(Acdc.this, Acdctwo.class);
u.putExtra("url", 8);
startActivity(u);
break;
case R.id.buttoneez9:
String j = "9";
Intent i = new Intent(Acdc.this, Acdctwo.class);
i.putExtra("url", 9);
startActivity(i);
break;
case R.id.buttoneez10:
String k = "10";
Intent o = new Intent(Acdc.this, Acdctwo.class);
o.putExtra("url", 10);
startActivity(o);
break;
case R.id.buttoneez11:
String l = "11";
Intent p = new Intent(Acdc.this, Acdctwo.class);
p.putExtra("url", 11);
startActivity(p);
break;
case R.id.buttoneez12:
String qq = "12";
Intent aa = new Intent(Acdc.this, Acdctwo.class);
aa.putExtra("url", 12);
startActivity(aa);
break;
case R.id.buttoneez13:
String ww = "13";
Intent ss = new Intent(Acdc.this, Acdctwo.class);
ss.putExtra("url", 13);
startActivity(ss);
break;
case R.id.buttoneez14:
String ee = "14";
Intent dd = new Intent(Acdc.this, Acdctwo.class);
dd.putExtra("url", 14);
startActivity(dd);
break;
case R.id.buttoneez15:
String ee1 = "15";
Intent dd1 = new Intent(Acdc.this, Acdctwo.class);
dd1.putExtra("url", 15);
startActivity(dd1);
break;
case R.id.buttoneez16:
String ee2 = "16";
Intent dd2 = new Intent(Acdc.this, Acdctwo.class);
dd2.putExtra("url", 16);
startActivity(dd2);
break;
case R.id.buttoneez17:
String ee3 = "17";
Intent dd3 = new Intent(Acdc.this, Acdctwo.class);
dd3.putExtra("url", 17);
startActivity(dd3);
break;
case R.id.buttoneez18:
String ee4 = "18";
Intent dd4 = new Intent(Acdc.this, Acdctwo.class);
dd4.putExtra("url", 18);
startActivity(dd4);
break;
default:
break;
// TODO Auto-generated method stub
}
// TODO Auto-generated method stub
}
}
这就是收到意图的地方
package com.surajmal.rocklegends2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Acdctwo extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent x=getIntent();
int y=x.getIntExtra("url", 0);
switch(y){
case 1:
setContentView(R.layout.acdc_tnt);
break;
case 2:
setContentView(R.layout.acdc_highvoltage);
break;
case 3:
setContentView(R.layout.acdc_letthereberock);
break;
case 4:
setContentView(R.layout.acdc_powerage);
break;
case 5:
setContentView(R.layout.acdc_blood);
break;
case 6:
setContentView(R.layout.acdc_black);
break;
case 7:
setContentView(R.layout.acdc_dirty);
break;
case 8:
setContentView(R.layout.acdc_forthose);
break;
case 9:
setContentView(R.layout.acdc_flick);
break;
case 10:
setContentView(R.layout.acdc_jailbreak);
break;
case 11:
setContentView(R.layout.acdc_fly);
break;
case 12:
setContentView(R.layout.acdc_whomade);
break;
case 13:
setContentView(R.layout.acdc_blow);
break;
case 14:
setContentView(R.layout.acdc_razor);
break;
case 15:
setContentView(R.layout.acdc_live);
break;
case 16:
setContentView(R.layout.acdc_highway);
break;
case 17:
setContentView(R.layout.acdc_ballbreaker);
break;
case 18:
setContentView(R.layout.acdc_bonfire);
break;
case 19:
setContentView(R.layout.acdc_stiff);
break;
case 20:
setContentView(R.layout.acdc_black);
break;
default:
setContentView(R.layout.metallica1);
break;
}
}
}
答案 0 :(得分:0)
package com.surajmal.rocklegends2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Acdc extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.acdc);
}
public void Button_Click(View v) {
switch (v.getId()) {
case R.id.buttoneez1:
String namaste = "1";
Intent dex = new Intent(Acdc.this, Acdctwo.class);
dex.putExtra("url", 1);
startActivity(dex);
finish();
break;
case R.id.buttoneez2:
String a = "2";
Intent q = new Intent(Acdc.this, Acdctwo.class);
q.putExtra("url", 2);
startActivity(q);
break;
case R.id.buttoneez3:
String b = "3";
Intent w = new Intent(Acdc.this, Acdctwo.class);
w.putExtra("url", 3);
startActivity(w);
break;
case R.id.buttoneez4:
String c = "4";
Intent e = new Intent(Acdc.this, Acdctwo.class);
e.putExtra("url", 4);
startActivity(e);
break;
case R.id.buttoneez5:
String d = "5";
Intent r = new Intent(Acdc.this, Acdctwo.class);
r.putExtra("url", 5);
startActivity(r);
break;
case R.id.buttoneez6:
String f = "6";
Intent t = new Intent(Acdc.this, Acdctwo.class);
t.putExtra("url", 6);
startActivity(t);
break;
case R.id.buttoneez7:
String g = "7";
Intent y = new Intent(Acdc.this, Acdctwo.class);
y.putExtra("url", 7);
startActivity(y);
break;
case R.id.buttoneez8:
String h = "8";
Intent u = new Intent(Acdc.this, Acdctwo.class);
u.putExtra("url", 8);
startActivity(u);
break;
case R.id.buttoneez9:
String j = "9";
Intent i = new Intent(Acdc.this, Acdctwo.class);
i.putExtra("url", 9);
startActivity(i);
break;
case R.id.buttoneez10:
String k = "10";
Intent o = new Intent(Acdc.this, Acdctwo.class);
o.putExtra("url", 10);
startActivity(o);
break;
case R.id.buttoneez11:
String l = "11";
Intent p = new Intent(Acdc.this, Acdctwo.class);
p.putExtra("url", 11);
startActivity(p);
break;
case R.id.buttoneez12:
String qq = "12";
Intent aa = new Intent(Acdc.this, Acdctwo.class);
aa.putExtra("url", 12);
startActivity(aa);
break;
case R.id.buttoneez13:
String ww = "13";
Intent ss = new Intent(Acdc.this, Acdctwo.class);
ss.putExtra("url", 13);
startActivity(ss);
break;
case R.id.buttoneez14:
String ee = "14";
Intent dd = new Intent(Acdc.this, Acdctwo.class);
dd.putExtra("url", 14);
startActivity(dd);
break;
case R.id.buttoneez15:
String ee1 = "15";
Intent dd1 = new Intent(Acdc.this, Acdctwo.class);
dd1.putExtra("url", 15);
startActivity(dd1);
break;
case R.id.buttoneez16:
String ee2 = "16";
Intent dd2 = new Intent(Acdc.this, Acdctwo.class);
dd2.putExtra("url", 16);
startActivity(dd2);
break;
case R.id.buttoneez17:
String ee3 = "17";
Intent dd3 = new Intent(Acdc.this, Acdctwo.class);
dd3.putExtra("url", 17);
startActivity(dd3);
break;
case R.id.buttoneez18:
String ee4 = "18";
Intent dd4 = new Intent(Acdc.this, Acdctwo.class);
dd4.putExtra("url", 18);
startActivity(dd4);
break;
default:
break;
// TODO Auto-generated method stub
}
// TODO Auto-generated method stub
}
布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Black" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttoneez1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/yeah23"
android:onClick="Button_Click"
android:text="TNT"
android:textColor="@color/White" />
<Button
android:id="@+id/buttoneez2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/buttoneez1"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="HIGH VOLTAGE"/>
<Button
android:id="@+id/buttoneez3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez2"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="LET THERE BE ROCK" />
<Button
android:id="@+id/buttoneez4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez3"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="POWERAGE" />
<Button
android:id="@+id/buttoneez5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez4"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="IF U WANT BLOOD" />
<Button
android:id="@+id/buttoneez6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez5"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="BACK IN BLACK" />
<Button
android:id="@+id/buttoneez7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez6"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="DIRTY DEEDS DONE CHEAP"/>
<Button
android:id="@+id/buttoneez8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez7"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="FOR THOSE ABOUT TO ROCK" />
<Button
android:id="@+id/buttoneez9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez8"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="FLICK OF THE SWITCH"/>
<Button
android:id="@+id/buttoneez10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez9"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="JAILBREAK" />
<Button
android:id="@+id/buttoneez11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez10"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="FLY ON THE WALL" />
<Button
android:id="@+id/buttoneez12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/buttoneez11"
android:background="@drawable/yeah23"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="WHO MADE WHO" />
<Button
android:id="@+id/buttoneez13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez12"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="BLOW UP YOUR VIDEO" />
<Button
android:id="@+id/buttoneez14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez13"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="THE RAZORS EDGE" />
<Button
android:id="@+id/buttoneez15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez14"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="HIGHWAY TO HELL" />
<Button
android:id="@+id/buttoneez16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez15"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="BALLBREAKER" />
<Button
android:id="@+id/buttoneez17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez16"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="BLACK ICE" />
<Button
android:id="@+id/buttoneez18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/buttoneez17"
android:background="@drawable/yeah23"
android:textColor="@color/White"
android:onClick="Button_Click"
android:text="THE RAZORS EDGE" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
答案 1 :(得分:0)
尝试这样做可能会帮助你一些
<强>的onCreate 强>
private ButtonClicked clicked = new ButtonClicked();
然后设置所有按钮的 onclickListner
buttonOn.setOnClickListener(clicked);
buttonSearch.setOnClickListener(clicked);
然后 ButtonClicked
class ButtonClicked implements OnClickListener {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.buttonOn:
on();
break;
case R.id.buttonSearch:
start();
break;
case R.id.buttonDesc:
makeDiscoverable();
break;
case R.id.off:
off();
break;
default:
break;
}
}
}