本文整理了Java中com.extjs.gxt.ui.client.widget.button.Button.getId()
方法的一些代码示例,展示了Button.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.getId()
方法的具体详情如下:
包路径:com.extjs.gxt.ui.client.widget.button.Button
类名称:Button
方法名:getId
暂无
代码示例来源:origin: stackoverflow.com
public void methodName(View v){
Button b = (Button) v;
int ID = b.getId();
if(ID == R.id.buttonId){
//DO SOMETHING FOR THIS BUTTON
}
else if(ID == R.id.anotherButtonId){
//DO SOMETHING FOR THIS BUTTON
}
...
}
代码示例来源:origin: stackoverflow.com
public void WriteValue (View sender) {
Button bt = (Button)sender;
if(bt.getId() == R.id.clearButtonId) {
Display.setText("0");
}
}
代码示例来源:origin: stackoverflow.com
public class MyButtonClickHandler implements View.OnClickListener {
@Override
public void onClick(View v) {
Button button = (Button) v;
if (button.getId() == R.id.button1) {
Toast.makeText(Sample1Activity.this, "Toast1", 1000).show();
} else if (button.getId() == R.id.button2) {
Toast.makeText(Sample1Activity.this, "Toast2", 1000).show();
}
}
}
代码示例来源:origin: stackoverflow.com
final Button nxtbtn = (Button) findViewById(R.id.Next);
nxtbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int ID = nxtbtn.getId();
if(ID == R.id.Next) // your R file will have all your id's in the literal form.
{
Log.e(TAG,""+ID);
}
}
});
代码示例来源:origin: stackoverflow.com
public void clicking(View v) {
Button button = (Button) v;
switch (button.getId()) {
case R.id.button0:
text.setText(text.getText().toString()
+ btn0.getText().toString());
break;
case R.id.button1:
text.setText(text.getText().toString()
+ btn1.getText().toString());
break;
and so on...
代码示例来源:origin: stackoverflow.com
public void onButtonClick(Button button){
// check here with button id
if(button.getId() == R.id.button1) {
} else if(button.getId() == R.id.button1) {
}
}
代码示例来源:origin: stackoverflow.com
for(Button b: buttons) {
if(b.getId().equals(your_id_to_check)) {
//DO WHAT YOU WANT
}
}
代码示例来源:origin: stackoverflow.com
void onClick(View v)
{
Button clickedButton = (Button) v;
// do what I need to do when a button is clicked here...
switch (clickedButton.getId())
{
case R.id.Button01:
// do something
break;
case R.id.Button01:
// do something
break;
}
}
代码示例来源:origin: stackoverflow.com
Button b = (Button) findViewWithTag("someTag");
int id = b.getId();
代码示例来源:origin: stackoverflow.com
for(Button b : Buttons){
Log.d("Have button with ID " + b.getId());
代码示例来源:origin: stackoverflow.com
@InjectView(R.id.btn1) Button btn1;
@InjectView(R.id.btn2) Button btn2;
...
@OnClick({R.id.btn1, R.id.btn2, R.id.btn3}) void onBtnClick(Button view) {
switch (view.getId()) {
case R.id.btn1:
// Do some staff
break;
case R.id.btn2:
// Do some staff
break;
}
}
...
代码示例来源:origin: stackoverflow.com
private void clickOnButtonByID(int ID) {
// get a list of all ImageButtons on the current activity
List<Button> btnList = solo.getCurrentButtons();
for (int i = 0; i < btnList.size(); i++) {
Button btn = btnList.get(i);
// find button by id
if (btn.getId() == ID) {
// click on the button using index (not id !!!)
solo.clickOnButton(i);
// check if new activity is the 'About'
} else {
// other code
}
}
}
代码示例来源:origin: stackoverflow.com
Object source = event.getSource();
if (source instanceof Button) { //should always be true in your example
Button clickedBtn = (Button) source; // that's the button that was clicked
System.out.println(clickedBtn.getId()); // prints the id of the button
}
代码示例来源:origin: stackoverflow.com
public void onClick(View v) {
// Perform action on click
String msg;
int id = v.getId();
Button inB = (Button) v.findViewById(id);
msg = "Clicked Button ID From Object " + inB.getId() + " Button";
Toast.makeText(v.getContext(), msg, Toast.LENGTH_LONG).show();
}
代码示例来源:origin: stackoverflow.com
public void onStop() {
SharedPreferences pref = // getPreferences;
Set<String> ids = new HashSet<String>();
for (Button button : buttons) {
if (button is pressed) {
ids.add(String.valueOf(button.getId()));
}
}
pref.edit().putStringSet(CURRENT_ACTIVITY_NAME, ids).commit();
}
public void onStart() {
SharedPreferences pref = // get preferences;
Set<String> ids = pref.getStringSet(CURRENT_ACTIVITY_NAME, Collections.emptySet<String>());
for (String id : ids) {
Button button = findViewById(Integer.parseInt(id));
set button pressed
}
}
代码示例来源:origin: stackoverflow.com
/*
* This is the common method used by all the buttons after the click
* was done in order to start the PreferenceActivity and pass
* the button id as a parameter
* @param sender - Button which was pressed and will start the
* PreferenceActivity
*/
private void startPreferenceActivity(Button sender)
{
// create the intent
Intent intent=new Intent(context, PreferenceActivity.class);
// add button id as a parameter
intent.putExtra("buttonID", sender.getId());
// start activity
startActivity(intent);
// or you can start it to way for a result
// startActivityForResult(intent, 0);
}
代码示例来源:origin: stackoverflow.com
public void onButtonClicker(View v)
{
Intent intent;
Button b1 = (Button)findViewById(R.id.hotels_bt);
.
.
switch (v.getId()) {
case (b1.getId()):
intent = new Intent(this, Hotels.class);
startActivity(intent);
break;
.
.
.
default:
break;
}
}
代码示例来源:origin: stackoverflow.com
public void onTileClicked(View view) {
Button button = (Button) view;
if(button.getId()==R.id.btn00)onTileClicked(0, 0, button);
else if(button.getId()==R.id.btn01)onTileClicked(0, 1, button);
else if(button.getId()==R.id.btn02)onTileClicked(0, 2, button);
else if(button.getId()==R.id.btn10)onTileClicked(1, 0, button);
else if(button.getId()==R.id.btn11)onTileClicked(1, 1, button);
else if(button.getId()==R.id.btn12)onTileClicked(1, 2, button);
else if(button.getId()==R.id.btn20)onTileClicked(2, 0, button);
else if(button.getId()==R.id.btn21)onTileClicked(2, 1, button);
else if(button.getId()==R.id.btn22)onTileClicked(2, 2, button);
}
代码示例来源:origin: stackoverflow.com
Button screen = (Button) findViewById (R.id.screen);
Drawable background = screen.getResources().getDrawable(screen.getId());
if(background == getResources().getDrawable(R.drawable.black)){
Drawable newBackgroun = getResources().getDrawable(R.drawable.white);
screen.setBackgroundDrawable(**newBackground**);
}
if(background == getResources().getDrawable(R.drawable.white)){
Drawable newBackgroun = getResources().getDrawable(R.drawable.black);
screen.setBackgroundDrawable(**newBackground**);
}
代码示例来源:origin: stackoverflow.com
public class ColorChanger
{
public void changeColor(Collection<Button> buttons)
{
for(Button b : buttons) {
changeButtonColor(b);
}
}
private void changeButtonColor(Button button) {
switch(button.getId()) {
case R.id.one:
button.setTextColor(0xFFFF0000);
break;
default:
// set default color?
break;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!