.


:




:

































 

 

 

 


FrameLayout




public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv1 = new TextView(this); tv1.setText(R.string.top_text); tv1.setTextSize(40); tv1.setTextColor(Color.BLACK); TextView tv2 = new TextView(this); tv2.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM)); tv2.setTextSize(50); tv2.setGravity(Gravity.RIGHT); tv2.setText(R.string.bottom_text); tv2.setTextColor(Color.WHITE); ImageView iv1 = new ImageView(this); iv1.setImageResource(R.drawable.lake); iv1.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); iv1.setScaleType(ScaleType.MATRIX); FrameLayout fl = new FrameLayout(this); fl.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); fl.addView(iv1); fl.addView(tv1); fl.addView(tv2); setContentView(fl);}

 

 

, , (),

Properties. , , Layouts, Widgets, Text Fields . Widgets ImageButton, . , , .

. . .

activity_main.xml. Properties, . , . , ImageButton TextView Hello World!. , , . , background. , . , , , .

Color , . FFC0CB #.

OK . .

, , RelativeLayout :

 

android:background="#ffffc0cb"

. . , .

background Project. New Resource... New Color Value.... . . , colors.xml. , strings.xml styles.xml, .

OK . :

 

android:background="@color/background_color"

. , , res/drawable-hdpi. , , .

.

, Drawable , . ImageButton src. Drawable - pinkhellokitty ( ).

, , . , .. .

onClick onClick - . , , onButtonPressed, .

. , TextView Hello, World (ID). , , . Widgets Large Text . .

- id. , @+id/textView. . , , . , . . Large Text. .

:

 

<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/background_color"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context="ru.alexanderklimov.hellokitty.MainActivity">

 

<ImageButton

android:id="@+id/imageButton"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_centerVertical="true"

android:onClick="onClick"

android:src="@drawable/pinkhellokitty" />

 

<TextView

android:id="@+id/textView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/imageButton"

android:layout_alignStart="@+id/imageButton"

android:layout_below="@+id/imageButton"

android:layout_marginTop="42dp"

android:text="Large Text"

android:textAppearance="?android:attr/textAppearanceLarge" />

 

</RelativeLayout>

"onClick" Alt + Enter

Create 'onClick(View)' in 'MainActivity'.

MainActivity .

MainActivity.java, . , . onCreate() :

 

private TextView mHelloTextView;

TextView mHelloTextView.

Enter, TextView import. , TextView .

onCreate() setContentView() :

 

mHelloTextView = (TextView)findViewById(R.id.textView); // , ?

, (Ctrl+) . . TextView , , .

.

 

public void onClick(View view) {

}

, :

 

mHelloTextView.setText("Hello Kitty!");

mHelloTextView setText() .

. , . - , XML-, .

app\build\outputs\apk APK-, ( ), .

,

 

// , ,

// , , .

 

package ru.alexanderklimov.hellokitty;

 

import android.app.Activity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.TextView;

 

 

public class MainActivity extends Activity {

 

private TextView mHelloTextView;

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

 

mHelloTextView = (TextView) findViewById(R.id.textView);

}

 

@Override

public 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;

}

 

@Override

public 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();

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

 

public void onClick(View view) {

mHelloTextView.setText("Hello Kitty!");

}

}

 

. Text Fields Plain Text , - . , hint -, .

 

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/editText"

android:layout_above="@+id/imageButton"

android:layout_centerHorizontal="true"

android:layout_marginBottom="66dp"

android:hint=" " />

MainActivity mHelloTextView:

 

private EditText mNameEditText;

onCreate():

 

mNameEditText = (EditText) findViewById(R.id.editText);

.

 

public void onClick(View view) {

if (mNameEditText.getText().length() == 0) {

mHelloTextView.setText("Hello Kitty!");

} else {

mHelloTextView.setText(", " + mNameEditText.getText());

}

}

. , - "Hello Kitty!". , . .

, . , Hellow World! , , TextView "Hellow World!" ( "Hellow World!" ) , Text , , ( , ):

< TextView

android:text="@string/hello_world"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentTop="true"

android:layout_centerHorizontal="true"

android:layout_marginTop="183dp"

 

android:textSize="25pt"/>

 

Preview .

! APK , , . , ( , ) Run, Run --- Run "app", Shift + F10. / . , Android !

 

1.4. , - . () . . (<activity>, <service>, <receiver>, <provider> ), . , , . . , , . Android:

 

,

nd - erfpfybtallowBackup

. ...

 

 

<activity

android:name="com.example.geodating.GS_selection"

android:label="@string/app_name"

android:theme="@android:style/Theme.Dialog"

android:configChanges="keyboardHidden|orientation" >

</activity>

<permission> , . , . (Activities, Services, Broadcast receivers Content providers) . , Android , .

<uses-permission> , . , .

:

INTERNET

READ_CONTACTS ( )

WRITE_CONTACTS ( )

RECEIVE_SMS SMS

ACCESS_FINE_LOCATION GPS

<uses-sdk> ( API) Android. API, , API , .

:

android:minSdkVersion API, . Android , , API , , .

android:maxSDKVersion , .

targetSDKVersion , .

<uses-configuration> . , , . , <uses-configuration> .

<uses-feature> , . , , . , , . , .

:

android.hardware.camera .

android.hardware.camera.autofocus .

<supports-screens> , . API 4 .

<application> , . (<activity>, <service>, <receiver>, <provider> ), , . <application>.

 

Palette. .

Form Widgets

TextView ()

Button ()

ToggleButton (-)

CheckBox ()

RadioButton ()

Spinner ( )

ProgressBar (Large, Normal, Small, Horizontal) -

SeekBar ()

QuickContactBadge

RatingBar ()

Switch ( )

ListPopupWindow

Text Fields

EditText ( )

AutoCompleteTextView (????????), MultiAutoCompleteTextView

Layouts

GridLayout

LinearLayout

RelativeLayout

FrameLayout

Include Other Layout

Fragment

TableLayout TableRow

Space

DrawerLayout

SlidingPanelLayout

SwipeRefreshLayout

BlinkLayout ()

CardView ().

 

 





:


: 2016-11-24; !; : 573 |


:

:

, , 1:10
==> ...

1710 - | 1640 -


© 2015-2024 lektsii.org - -

: 0.121 .