NotePad Project (2)
Note Pad Project (2)
===============
Activity ၂ခုပါမယ္။ MainActivity နဲ႔ NoteActivity ။
MainActivity က main.xml, NoteActivity က note_layout.xml ကို setContentView နဲ႔ ဆြဲတင္ရမယ္။
main.xml မွာ ListView တခုကို အျပည့္ ျဖန္႔ထည့္ၿပီး ID ကို lv လို႔ ေပးပါ။
note_layout.xml မွာ EditText တခုကို အျပည့္ ျဖန္႔ထည့္ၿပီး ID ကို et လို႔ ေပးပါ။
NoteActivity ကို AndroidManifest.xml မွာ ေၾကျငာေပးရပါမယ္။
==========
main.xml
========
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ListView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/lv"/>
</LinearLayout>
========
MainActivity.java
========
package nnl.aide.lessons;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
import android.widget.AdapterView.*;
public class MainActivity extends Activity
{
ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv=(ListView)findViewById(R.id.lv);
}
}
=========
note_layout.xml
=========
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<EditText
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:layout_width="match_parent"
android:id="@+id/et"
android:gravity="top|left"/>
</LinearLayout>
=========
NoteActivity.java
=========
package nnl.aide.lessons;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
public class NoteActivity extends Activity
{
EditText et;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.note_layout);
et=(EditText)findViewById(R.id.et);
}
}
=========
AndroidManifest.xml
=========
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nnl.aide.lessons" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NoteActivity"
>
</activity>
</application>
</manifest>
=========
#notepad
#nnl
AIDE Android Lessons And Project Group
ဆရာ Nyi Nyi Lwin Post မွ ကူးယူတင္ထားပါသည္
#Credit ဆရာ Nyi Nyi Lwin
Comments
Post a Comment
Thank,s for ...