導航:首頁 > 操作系統 > android開發button

android開發button

發布時間:2022-11-02 09:57:37

android開發中點擊button無反應大神來看看這個代碼的問題在哪裡

把 button_listener = new Button.OnClickListener() {
public void onClick(View v) {
//setTitle("哎呦,button被點了一下");
Intent intent=new Intent(MainActivity.this,edText.class);
startActivity(intent);
} 這段放到 onCreate 方法外面

Button.OnClickListener button_listener = new Button.OnClickListener() {
public void onClick(View v) {
//setTitle("哎呦,button被點了一下");
Intent intent=new Intent(MainActivity.this,edText.class);
startActivity(intent);
}

② android開發 如何隨機選button

10個button的引用放到MAP<int,Button>中,key為1-10,value為10個button的引用,
然後取1-10隨機數,再通過取到的隨機數去map中取button
OK了

③ 如何在android當中實現Button操作

你可以現在布局文件layout中添加button控制項,然後對其屬性設置,最後在src文件中,編寫java文件,對該按鈕的功能進行設置,並監聽按鈕事件

④ Android開發中,如何給動態生成的Button指定Style樣式

自定義樣式方法,可以直接通過定義xml文件來實現不同的樣式:
只需要修改button_style文件,同樣三種狀態分開定義:
Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient android:startColor="#0d76e1" android:endColor="#0d76e1"
android:angle="270" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="2dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>

<item android:state_focused="true">
<shape>
<gradient android:startColor="#ffc2b7" android:endColor="#ffc2b7"
android:angle="270" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="2dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>

<item>
<shape>
<gradient android:startColor="#000000" android:endColor="#ffffff"
android:angle="180" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="5dip" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>
</selector>

gradient 主體漸變 startColor開始顏色,endColor結束顏色 ,angle開始漸變的角度(值只能為90的倍數,0時為左到右漸變,90時為下到上漸變,依次逆時針類推)
stroke 邊框 width 邊框寬度,color 邊框顏色
corners 圓角 radius 半徑,0為直角
padding text值的相對位置

⑤ android中button有幾種狀態

Android中,button按鈕通常有三個狀態:

1. normal(正常狀態);
2. focus(焦點狀態);
3. pressed(按下狀態)
4. selected(選中狀態)

注意:按下後未松開前是pressed,表示按下。
松開後當前項目獲得焦點,是focused。
focused的項只有一個,selected是當選中該按鈕時顯示的狀態。

⑥ Android 開發裡面如何點擊Button將EditText裡面的內容顯示在textView里

1、添加button的單擊事件
2、獲取edittext的內容
3、往textview中賦值
示例:
Button btn = (Button)findViewById(R.id.xxx);//獲取按鈕
btn.setOnClickListener(new View.OnClickListener() {
//設置按鈕單擊事件
@Override
public void onClick(View v) {
EditText et = (EditText)findViewById(R.id.xxxx);//獲取edittext組件
TextView tv = (TextView)findViewById(R.id.xxxx);//獲取textview組件
String cn = et.getText().toString();//獲取edittext中填寫的內容
tv.setText(cn);//在textview中顯示
}
});

⑦ android開發中,button的text(settext方法)可以動態的設置嗎

可以。

1、通過id獲取button組件

Buttonbtn=(Button)findViewById(R.id.xxxx);//獲取button組件對象

2、通過setText方法改變button的text屬性

btn.setText("改變後的值");//改變button的文本顯示
閱讀全文

與android開發button相關的資料

熱點內容
編譯壓縮 瀏覽:648
工廠程序員翻車 瀏覽:31
鄭州程序員一個月工資 瀏覽:660
證券公司招聘程序員 瀏覽:879
java高級編程jdk7 瀏覽:442
java加密狗 瀏覽:951
lisp編程工具 瀏覽:643
加密貨幣軟錢包排行 瀏覽:833
exe文件反編譯源碼工具下載 瀏覽:40
python6bit灰度圖 瀏覽:736
如何用java編譯東西 瀏覽:825
php多語言包管理方案 瀏覽:254
python程序運行時間自動控制 瀏覽:385
java編譯主函數快捷鍵 瀏覽:787
atom編輯器python 瀏覽:182
安卓優學派如何恢復出廠設置 瀏覽:730
程序員女巫 瀏覽:784
冷凍冷藏壓縮機 瀏覽:854
吉利紅包H5編譯教程 瀏覽:635
ftpsocket編程 瀏覽:692