日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

重温5 UI开发

發(fā)布時間:2023/12/2 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 重温5 UI开发 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
public class

TextView

extends View

implements ViewTreeObserver.OnPreDrawListener
java.lang.Object
????android.view.View
?????android.widget.TextView
Known Direct Subclasses Button,CheckedTextView,Chronometer,DigitalClock,EditText,TextClock
ButtonRepresents a push-button widget.?
CheckedTextViewAn extension to TextView that supports the Checkable interface.?
ChronometerClass that implements a simple timer.?
DigitalClockThis class was deprecated in API level 17. It is recommended you useTextClock instead.?
EditTextEditText is a thin veneer over TextView that configures itself to be editable.?
TextClock

TextClock can display the current date and/or time as a formatted string.?

Known Indirect Subclasses AutoCompleteTextView,CheckBox,CompoundButton,ExtractEditText,MultiAutoCompleteTextView,RadioButton,Switch,ToggleButton
1、fill_parent與match_parent Android2.2開始兩者相同,2.2之前用fill_parent,官方推薦match_parent。 2、layout_gravity與gravity 2.1)gravity:指定控件中文字的對齊方式。 layout_gravity:指定控件在所在布局中的對齊方式。 LinearLayout中: orientation:vertical時:layout_gravity水平方向的設(shè)置有效:left/right/center_horizontal orientation:horiaontal時:layout_gravity垂直方向設(shè)置有效:top/bottom/center_vertical. ?center 都可以用,總有一個方向生效 2.2)想要設(shè)置某個控件居底,可以在空間外加一層LinearLayout并設(shè)置其gravity為bottom. <LinearLayout ... android:gravity="bottom" ...><Button ....../> </LinearLayout>3、Button點擊事件 3.1)XML:?<Button ... android:onClick="onClick"/><!--點擊事件的方法名-->
public void onClick(View view){ }3.2)? login_btn.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View view){}}});//匿名類的方式3.3) public class MainActivity extends Activity implements onClickListener{@Overrideprotected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);Button button = (Button)findViewById(R.id.button);button.setOnClickListener(this); }@Overridepublic void onClick(View view){ } } 3.4) Button Btn = (Button) findViewById(R.id.button); Btn2.setOnClickListener(listener);//設(shè)置監(jiān)聽 } Button.OnClickListener listener = new Button.OnClickListener(){//創(chuàng)建監(jiān)聽對象 public void onClick(View v){ } }; 4、EditText 當需要輸入EditText中的內(nèi)容過多時,可以指定最大行數(shù),當達到最大行數(shù)時文本就會往上滾動。 android:maxLines="2"5、ProgressBar/AlertDialog/ProgressDialog
<ProgressBarandroid:id="@+id/progressBar"android:layout_width="wrap_content"android:layout_height="wrap_content"/><!-- 可以設(shè)置style="?android:attr/progressBarStyleHorizontal"android:max="100"-->//AlertDialog/ProgressDialog@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();switch(id){case R.id.alertDialog:AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);alertDialog.setTitle("Warning");alertDialog.setMessage("This is a warning");alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stub}});alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stub}});alertDialog.show();break;case R.id.progressDialog:ProgressDialog progressDialog = new ProgressDialog(this);progressDialog.setTitle("ProgressDialog");progressDialog.setMessage("loading...");progressDialog.show();break;default:}return super.onOptionsItemSelected(item);}




完整代碼在:https://github.com/HiSunny/ComeOnProgressBarAlertDialogProgressDialog.git

總結(jié)

以上是生活随笔為你收集整理的重温5 UI开发的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。