[Android] android Program Interface Programming and View Components

Source: Internet
Author: User

import android.widget.EditText;import android.widget.ImageButton;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.PopupWindow;import android.widget.RadioButton;import android.widget.RadioGroup;import android.widget.RelativeLayout;import android.widget.SeekBar;import android.widget.CompoundButton.OnCheckedChangeListener;import android.widget.SeekBar.OnSeekBarChangeListener;import android.widget.TextView;import android.widget.Toast;import android.widget.ViewSwitcher;

Related Methods Description
SetVilibility (int) Set whether the component is visible

Android: layout_height Height of the Child widget Layout
Android: layout_width Specify the layout width of the Child widget.
android:layout_width="fill_parent"android:layout_height="wrap_content"

XML attributesRelated MethodsDescriptionAndroid: layout_marginBottomSetMargins (int, int)The margin of the Child widget.Android: layout_marginLeftSetMargins (int, int)The margin on the left of the Child widget.Android: layout_marginRightSetMargins (int, int)The margin on the Right of the Child widget.Android: layout_marginTopSetMargins (int, int)The margin above the child widget.

android:layout_marginTop="10dp" android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:layout_marginBottom="10dp"

<TextView android: id = "@ + id/show_helloworld" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = "I implemented the XML layout file" android: textColor = "@ color/LightOrange"/>

setContentView(R.layout.main);

private Text showText;
showText = (Text) findViewById(R.id.show_helloworld);

// Create a linear layout manager LinearLayout layout = new LinearLayout (this); // set anctilayout to display layoutsuper. setContentView (layout); layout. setOrientation (LinearLayout. VERTICAL); // create a TextViewfinal TextView textView = new TextView (this); textView. setText ("I implemented it through java code ...... "); Layout. addView (textView );
In the MainActivity class, call:

showText = (Button) findViewById(R.id.show_helloworld);showText.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubIntent intent = new Intent(MainActivity.this,JavaActivity.class);startActivity(intent);}});








 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.