Java Lesson17 မွာ ဆက္ေလ့လာရမယ့္ကုဒ္


=============================

Java Lesson17 သင္ခန္းစာမွာ User ႐ိုက္သြင္းသမ်ွတန္ဖိုးေတြကုိ System ကေန အသံနဲ႔လိုက္ဖတ္ျပေပးမယ့္ ကုဒ္ပါ... ေလာေလာဆယ္ Error ႐ွိေပမယ့္ မရရေအာင္ျပင္ၾကည့္ထားပါတယ္... အသံုးျပဳလို႔ေတာ့ရေနပါၿပီ...ဒါေပမယ့္ လိုအပ္ခ်က္႐ွိေနေသးတာမို႔ ေလ့လာ႐ုံေလ့လာထားၾကပါ... က်ေနာ္ကုိယ္တိုင္လည္ေနၿပီမို႔ သင္ခန္းစာခဏရပ္ထားပါမယ္...

အမွန္က ပထမနည္းသုံးတာ ဘာ Error မွမ႐ွိဘူးဗ်။ ဒါေပမယ့္ ႐ိုက္သမ်ွဂဏန္းေတြသူက အစအဆုံးျပန္ျပန္ရြတ္ျပေနတယ္... က်ေနာ္က ႐ိုက္လိုက္တဲ့စာလုံးပဲရြတ္ျပေစခ်င္တာေလ... သူက႐ိုက္လိုက္တိုင္းအစကေနျပန္ျပန္ရြတ္ျပေနေတာ့ မနိပ္ဖူးေပါ့ဗ်ာ...

ဒါနဲ႔နည္းအမ်ိဳးမ်ိဳးထပ္စမ္းၿပီး ခုနည္းကသာေလာေလာဆယ္အဆင္ေျပသမို႔ခ်ေရးလိုက္ပါတယ္... သူကေတာ့ Error ပါတယ္ဗ်ိဳ႕... တျခားမဟုတ္ဘူး... App တက္လာလာျခင္း အသံခ်က္ခ်င္းမလာတတ္ဘူး ခဏေစာင့္ေပးရတယ္... ၿပီးရင္ Back space နဲ႔အကုန္႐ွင္းတဲ့အခါ pj out သြားပါေလေရာ... ဒါကုိ try catch နဲ႔ေလာေလာဆယ္႐ွင္းထားပါတယ္... ဒီကေနဆက္ေလ့လာၿပီး ကြကုိယ္အသုံးခ်ေပေတာ့.. ေလာေလာဆယ္ က်ေနာ္ကုိယ္တိုင္လည္ေနတာမို႔ ကြကုိယ္သင္တန္းျပန္ေပးရဦးမယ္ 😅😅😅😅

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"
android:orientation="vertical">

<EditText
android:id="@+id/et"
android:layout_height="wrap_content"
android:ems="10"
android:hint="ဒီမွာ Bill ေငြျဖည့္ကုဒ္ထည့္ပါ"
android:layout_width="wrap_content"/>

<Button
android:id="@+id/bt"
android:text="Bill ျဖည့္ရန္"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"/>

</LinearLayout>

MainActivity.java
===============
package com.ktr.billll;

import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;
import android.net.*;
import android.content.*;
import android.speech.tts.*;
import java.util.*;
import android.text.*;

public class MainActivity extends Activity
{
EditText et;
Button bt;
TextToSpeech tts;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

et = (EditText)findViewById(R.id.et);
bt = (Button)findViewById(R.id.bt);


tts = new TextToSpeech(this,new TextToSpeech.OnInitListener(){
public void onInit(int status){
if(status != TextToSpeech.ERROR){
tts.setLanguage(Locale.US);

}
}
});


et.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start, int before, int count) {

try{
String speak = s.toString();
speak = speak.substring(speak.length() - 1);
tts.speak(speak,TextToSpeech.QUEUE_FLUSH,null);
}catch(Exception e){
Toast.makeText(MainActivity.this,"BackSpace Error",5000).show();
}


}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}
public void afterTextChanged(Editable s) {

}
});
                            



bt.setOnClickListener(new OnClickListener(){
public void onClick(View v){
String str = et.getText().toString();
startActivity(new Intent(Intent.ACTION_CALL,
Uri.parse("tel:*123*"+str+"%23")));

}
});


    }

}

Comments

Popular posts from this blog

Firebase (2)

Story Book Project (8)

Story Book Project (7)