• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to use tamil fonts in android mobile

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i want to introduce Tamil fonts into my mobile and want to get an display message called "vanakkam" in " வனக்கம் " from the search in tamil . so i need to install Tamil font inside the coding, what type of fonts and what is the procedure to install Tamil fonts in the code ? can any one reply this it would be helpful for many people who want to introduce and use Tamil font and create an application for that.
 
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI !

First, create in your project two folders :
+
MainProjectName
|
|--- assets
|---- fonts
|
|
+

put any font you want to use, in fonts folder

Now, you can load them into Typeface object :



So, you can now, set, for example Textview by invoking setTypeface method, font that will be used instead default fonts

That's all
BYE (sorry for my english, Im still learning)
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i still have an doubt. where i need to add these two codes in my code?


can any one tell me more clearly. i have downloaded the font and installed in that place.but it is in .exe format. i am confused. help me.
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

You need to put this two lines of code in any place in your program that you want to use those font For example : in class that extends activity base class, at onCreate method



Bye
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i am not getting any error in the comipilation time but during run time i am getting an error that " the application HelloWorld (process com.mkyong.android) has stopped unexpectedly. please try again. "

for this code. can you tell me why is it happening so and i would like to know why such errors coming during run time because for most of the programming time the developers get an run time error and it is difficult to spot out the error.

i have attached an coding to print the tamil word. the coding is as below





main.xml is
<?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" >

<ListView android:id="@+id/ListView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />

</LinearLayout>

can we solve this problem and can share the reason why such errors coming during run time?
 
Saloon Keeper
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the logcat output; there'll be a stack trace of the exception - that should point you to the problem.
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya . i am getting an error message like this

05-04 11:17:08.399: D/AndroidRuntime(334): Shutting down VM
05-04 11:17:08.399: W/dalvikvm(334): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-04 11:17:08.479: E/AndroidRuntime(334): FATAL EXCEPTION: main
05-04 11:17:08.479: E/AndroidRuntime(334): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mkyong.android/com.mkyong.android.HelloWorldActivity}: java.lang.RuntimeException: native typeface cannot be made
05-04 11:17:08.479: E/AndroidRuntime(334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.os.Looper.loop(Looper.java:123)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-04 11:17:08.479: E/AndroidRuntime(334): at java.lang.reflect.Method.invokeNative(Native Method)
05-04 11:17:08.479: E/AndroidRuntime(334): at java.lang.reflect.Method.invoke(Method.java:507)
05-04 11:17:08.479: E/AndroidRuntime(334): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-04 11:17:08.479: E/AndroidRuntime(334): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-04 11:17:08.479: E/AndroidRuntime(334): at dalvik.system.NativeStart.main(Native Method)
05-04 11:17:08.479: E/AndroidRuntime(334): Caused by: java.lang.RuntimeException: native typeface cannot be made
05-04 11:17:08.479: E/AndroidRuntime(334): at android.graphics.Typeface.<init>(Typeface.java:147)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.graphics.Typeface.createFromAsset(Typeface.java:121)
05-04 11:17:08.479: E/AndroidRuntime(334): at com.mkyong.android.HelloWorldActivity.onCreate(HelloWorldActivity.java:13)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-04 11:17:08.479: E/AndroidRuntime(334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-04 11:17:08.479: E/AndroidRuntime(334): ... 11 more
05-04 11:17:10.898: I/Process(334): Sending signal. PID: 334 SIG: 9
05-04 11:18:48.799: D/AndroidRuntime(403): Shutting down VM
05-04 11:18:48.799: W/dalvikvm(403): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-04 11:18:48.859: E/AndroidRuntime(403): FATAL EXCEPTION: main
05-04 11:18:48.859: E/AndroidRuntime(403): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mkyong.android/com.mkyong.android.HelloWorldActivity}: java.lang.RuntimeException: native typeface cannot be made
05-04 11:18:48.859: E/AndroidRuntime(403): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.os.Looper.loop(Looper.java:123)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-04 11:18:48.859: E/AndroidRuntime(403): at java.lang.reflect.Method.invokeNative(Native Method)
05-04 11:18:48.859: E/AndroidRuntime(403): at java.lang.reflect.Method.invoke(Method.java:507)
05-04 11:18:48.859: E/AndroidRuntime(403): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-04 11:18:48.859: E/AndroidRuntime(403): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-04 11:18:48.859: E/AndroidRuntime(403): at dalvik.system.NativeStart.main(Native Method)
05-04 11:18:48.859: E/AndroidRuntime(403): Caused by: java.lang.RuntimeException: native typeface cannot be made
05-04 11:18:48.859: E/AndroidRuntime(403): at android.graphics.Typeface.<init>(Typeface.java:147)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.graphics.Typeface.createFromAsset(Typeface.java:121)
05-04 11:18:48.859: E/AndroidRuntime(403): at com.mkyong.android.HelloWorldActivity.onCreate(HelloWorldActivity.java:12)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-04 11:18:48.859: E/AndroidRuntime(403): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-04 11:18:48.859: E/AndroidRuntime(403): ... 11 more
05-04 11:18:51.059: I/Process(403): Sending signal. PID: 403 SIG: 9
05-04 11:21:14.409: D/AndroidRuntime(438): Shutting down VM
05-04 11:21:14.449: W/dalvikvm(438): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-04 11:21:14.469: E/AndroidRuntime(438): FATAL EXCEPTION: main
05-04 11:21:14.469: E/AndroidRuntime(438): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mkyong.android/com.mkyong.android.HelloWorldActivity}: java.lang.RuntimeException: native typeface cannot be made
05-04 11:21:14.469: E/AndroidRuntime(438): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.os.Looper.loop(Looper.java:123)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-04 11:21:14.469: E/AndroidRuntime(438): at java.lang.reflect.Method.invokeNative(Native Method)
05-04 11:21:14.469: E/AndroidRuntime(438): at java.lang.reflect.Method.invoke(Method.java:507)
05-04 11:21:14.469: E/AndroidRuntime(438): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-04 11:21:14.469: E/AndroidRuntime(438): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-04 11:21:14.469: E/AndroidRuntime(438): at dalvik.system.NativeStart.main(Native Method)
05-04 11:21:14.469: E/AndroidRuntime(438): Caused by: java.lang.RuntimeException: native typeface cannot be made
05-04 11:21:14.469: E/AndroidRuntime(438): at android.graphics.Typeface.<init>(Typeface.java:147)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.graphics.Typeface.createFromAsset(Typeface.java:121)
05-04 11:21:14.469: E/AndroidRuntime(438): at com.mkyong.android.HelloWorldActivity.onCreate(HelloWorldActivity.java:15)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-04 11:21:14.469: E/AndroidRuntime(438): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-04 11:21:14.469: E/AndroidRuntime(438): ... 11 more
05-04 11:21:16.749: I/Process(438): Sending signal. PID: 438 SIG: 9
05-04 11:22:08.519: D/AndroidRuntime(471): Shutting down VM
05-04 11:22:08.609: W/dalvikvm(471): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-04 11:22:08.639: E/AndroidRuntime(471): FATAL EXCEPTION: main
05-04 11:22:08.639: E/AndroidRuntime(471): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mkyong.android/com.mkyong.android.HelloWorldActivity}: java.lang.RuntimeException: native typeface cannot be made
05-04 11:22:08.639: E/AndroidRuntime(471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.os.Looper.loop(Looper.java:123)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-04 11:22:08.639: E/AndroidRuntime(471): at java.lang.reflect.Method.invokeNative(Native Method)
05-04 11:22:08.639: E/AndroidRuntime(471): at java.lang.reflect.Method.invoke(Method.java:507)
05-04 11:22:08.639: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-04 11:22:08.639: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-04 11:22:08.639: E/AndroidRuntime(471): at dalvik.system.NativeStart.main(Native Method)
05-04 11:22:08.639: E/AndroidRuntime(471): Caused by: java.lang.RuntimeException: native typeface cannot be made
05-04 11:22:08.639: E/AndroidRuntime(471): at android.graphics.Typeface.<init>(Typeface.java:147)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.graphics.Typeface.createFromAsset(Typeface.java:121)
05-04 11:22:08.639: E/AndroidRuntime(471): at com.mkyong.android.HelloWorldActivity.onCreate(HelloWorldActivity.java:15)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-04 11:22:08.639: E/AndroidRuntime(471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-04 11:22:08.639: E/AndroidRuntime(471): ... 11 more
05-04 11:27:08.708: I/Process(471): Sending signal. PID: 471 SIG: 9
05-04 11:53:08.538: D/AndroidRuntime(502): Shutting down VM
05-04 11:53:08.598: W/dalvikvm(502): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-04 11:53:08.648: E/AndroidRuntime(502): FATAL EXCEPTION: main
05-04 11:53:08.648: E/AndroidRuntime(502): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mkyong.android/com.mkyong.android.HelloWorldActivity}: java.lang.RuntimeException: native typeface cannot be made
05-04 11:53:08.648: E/AndroidRuntime(502): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.os.Looper.loop(Looper.java:123)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-04 11:53:08.648: E/AndroidRuntime(502): at java.lang.reflect.Method.invokeNative(Native Method)
05-04 11:53:08.648: E/AndroidRuntime(502): at java.lang.reflect.Method.invoke(Method.java:507)
05-04 11:53:08.648: E/AndroidRuntime(502): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-04 11:53:08.648: E/AndroidRuntime(502): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-04 11:53:08.648: E/AndroidRuntime(502): at dalvik.system.NativeStart.main(Native Method)
05-04 11:53:08.648: E/AndroidRuntime(502): Caused by: java.lang.RuntimeException: native typeface cannot be made
05-04 11:53:08.648: E/AndroidRuntime(502): at android.graphics.Typeface.<init>(Typeface.java:147)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.graphics.Typeface.createFromAsset(Typeface.java:121)
05-04 11:53:08.648: E/AndroidRuntime(502): at com.mkyong.android.HelloWorldActivity.onCreate(HelloWorldActivity.java:15)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-04 11:53:08.648: E/AndroidRuntime(502): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-04 11:53:08.648: E/AndroidRuntime(502): ... 11 more
05-04 12:03:12.199: D/AndroidRuntime(531): Shutting down VM
05-04 12:03:12.199: W/dalvikvm(531): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-04 12:03:12.289: E/AndroidRuntime(531): FATAL EXCEPTION: main
05-04 12:03:12.289: E/AndroidRuntime(531): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mkyong.android/com.mkyong.android.HelloWorldActivity}: java.lang.RuntimeException: native typeface cannot be made
05-04 12:03:12.289: E/AndroidRuntime(531): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.os.Looper.loop(Looper.java:123)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-04 12:03:12.289: E/AndroidRuntime(531): at java.lang.reflect.Method.invokeNative(Native Method)
05-04 12:03:12.289: E/AndroidRuntime(531): at java.lang.reflect.Method.invoke(Method.java:507)
05-04 12:03:12.289: E/AndroidRuntime(531): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-04 12:03:12.289: E/AndroidRuntime(531): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-04 12:03:12.289: E/AndroidRuntime(531): at dalvik.system.NativeStart.main(Native Method)
05-04 12:03:12.289: E/AndroidRuntime(531): Caused by: java.lang.RuntimeException: native typeface cannot be made
05-04 12:03:12.289: E/AndroidRuntime(531): at android.graphics.Typeface.<init>(Typeface.java:147)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.graphics.Typeface.createFromAsset(Typeface.java:121)
05-04 12:03:12.289: E/AndroidRuntime(531): at com.mkyong.android.HelloWorldActivity.onCreate(HelloWorldActivity.java:15)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-04 12:03:12.289: E/AndroidRuntime(531): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-04 12:03:12.289: E/AndroidRuntime(531): ... 11 more

how to solve this. i am using eclipse for my project.
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

Firstly you should download tamil fonts, I used this one : Download the tamil fonts, rename it to font1.ttf and put in assets/fonts folder.

Secondly :

Everything with code below is OK, runtime error does appear because, you try to load fonts that not exists in assets/fonts folder.



You don't need any xml layout files in that simple project

Bye!
Sorry for my English
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya it works fine thanks. how could you find the error from that catlog that the font is needed? i could not recognize it . how to find like this error in future?
but still a problem when comes under the array format. i am getting an error in this line and not able to solve it.

error : listView.Typeface(tf); it tells that add cast to listView

[code = android]
public class ListFruitActivity extends ListActivity {

static final String[] FRUITS = new String[] { "ஆப்பிள்", "அவோகாடோ", "பாணன்",
"ப்லுபெர்ரி", "கோகோனுட்", "Durian", "Guava", "Kiwifruit",
"Jackfruit", "Mango", "Olive", "Pear", "Sugar-apple" };

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/TABUni-Tamil021.ttf");
tf = Typeface.create(tf, Typeface.BOLD);
// no more this
// setContentView(R.layout.list_fruit);

setListAdapter(new ArrayAdapter<String>(this, R.layout.list_fruit,
FRUITS));

ListView listView = getListView();
listView.setTextFilterEnabled(true);

//listView.setText("வனக்கம்");
listView.Typeface(tf);
setContentView(listView);

listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(),
((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}


});

}

}
[/code]

is there any changes need to be made when it comes to array in the code. or is it same ?
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Take a look at code below, this is very simple example :



Bye
Where are you from ?
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wait a min. please there is an error exists when i put the code . i get an error in this line

super(WidgetActivity.this, R.layout.row, FRUITS); //super class constructor

and i have made slight variation in the code here

TextView tamil = (TextView) row.findViewById(R.id.EditText01);
tamil.setText(FRUITS[0][position] + " - ");
tamil.setTypeface(tamilTypeface);

TextView normal = (TextView) row.findViewById(R.id.ListView01);
normal.setText(FRUITS[1][position]);
normal.setTypeface(normalTypeface);


it tells WidgetActivity cannot be resolved to a type and showing from 7 points such as create class, enum like that etc..

row.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="20sp" >

<EditText android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="Search">
</EditText>

<ListView android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
</TextView>

and i am from Chennai. why this question may i know ?
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

Sorry, I forgot add xml file that represents a single row :/

row.xml



I am from Poland, it's in center of the europe, you can see my town in google earth, close to Zory - Pawlowice, Jastrzebie, south Poland . I always wanted to have a friend somewhere on the Earth

Greetings from Poland
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya it's nice to meet you. the same error exists in the code in that line it is not resolved.

entire code is

package com.myactivity;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class MyActivity extends Activity {

private static final String[][] FRUITS = {
{"ஆப்பிள்", "அவோகாடோ", "பாணன்"},{"Durian", "Guava", "Kiwifruit"}
};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


ListView listView = new ListView(this);; //just simple ListView
listView.setAdapter(new MyAdapter()); //MyAdapter is private class that extends ArrayAdapter where I can create my own view

setContentView(listView); // here we put view and set them
}

private class MyAdapter extends ArrayAdapter {
private Typeface tamilTypeface, normalTypeface;

public MyAdapter() {
super(WidgetActivity.this, R.layout.row, FRUITS); //super class constructor

tamilTypeface = Typeface.createFromAsset(getAssets(), "fonts/tamil1.ttf");
normalTypeface = Typeface.createFromAsset(getAssets(), "fonts/normal1.ttf");
}

public View getView(int position, View convertView, ViewGroup parrent) {
View row = convertView;

if (row == null) {
LayoutInflater inflater = getLayoutInflater();

row = inflater.inflate(R.layout.row, parrent, false); // inflate view from xml file
}

//Below two textView

TextView tamil = (TextView) row.findViewById(R.id.tamil);
tamil.setText(FRUITS[0][position] + " - ");
tamil.setTypeface(tamilTypeface);

TextView normal = (TextView) row.findViewById(R.id.normal);
normal.setText(FRUITS[1][position]);
normal.setTypeface(normalTypeface);

return row;
}

}
}

i am using eclipse 2.3.3 for this application
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be

 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wow.. superb... it's fine working.. jolly... thanks a lot...
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome.
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

It's my fault, I was copied it from my project which is called : Widget

public MyAdapter() {
super(WidgetActivity.this, R.layout.row, FRUITS);

I forgot to change it from WidgetActivity.this to MyActivity.this

Sorry ...
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya never mind.. some body corrected it it's working fine. thanks for the code. it might be helpful to many people who are developing for Tamil. any ways thanks ..
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

Good noon. in the above code i have the names for 3 different words. but it's result is displayed for only first two. why is it so ?
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

The construction of structure that contain words isn't good, I made it as simple as possible but not very good

Add FRUIT[0] in constructor of MyAdapter class to show all words in array. It's because the array contains 2 arrays of 3 words (tamoe, and normal) [0][0] .. [0][1] ... [0][2], and the second [1][0] .. [1][1] .. [1][2]

Try to make your own structure that will contain pairs of words tamoe - normal .

Bye
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you mean to tell to change this line of the code

tamil.setText(FRUITS[0][position]);

to

tamil.setText(FRUITS[0][0].. [0][1].. [0][2]+ " - ");

you telling to change like this ?
if i put like that it shows some error in the dots. sorry i am new to android and i am not aware of all the coding in java. i am learning myself to complete my project. so not very sure of using my own function now.
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Uuu, I see that you have large gaps of Java programming, it would be better for you, if you will start to learn Java (Standard Edition) from begin. You should register at http://knowledgeblackbelt.com/ and try do gain at least orange belt in Java programming, I can recommend you good book to gain more knowledge and experience in programing: Thinking in Java, it is realy good book.

When you'll be more experienced in Java programming then you may start having fun with Android programming. Of course, you can try only in Android but as you can see, you have large gaps in knowledge. So, dont give up, and start learning Java NOW. ;)



Bye
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i wanted to create an search box for this query but i get some errors in the code? i am not sure where to use this for creating an search box supporting for English and Tamil can any one tell me ?

here is the code which is there without search box

package com.WidgetActivity;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class WidgetActivity extends Activity {

private static final String[][] FRUITS = {
{"ஆப்பிள்", "அவோகாடோ", "பாணன்"},{"Durian", "Guava", "Kiwifruit"}
};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


ListView listView = new ListView(this);; //just simple ListView
listView.setAdapter(new MyAdapter()); //MyAdapter is private class that extends ArrayAdapter where I can create my own view

setContentView(listView); // here we put view and set them
}

private class MyAdapter extends ArrayAdapter {
private Typeface tamilTypeface, normalTypeface;

public MyAdapter() {
super(WidgetActivity.this, R.layout.row, FRUITS); //super class constructor

tamilTypeface = Typeface.createFromAsset(getAssets(), "fonts/TABUni-Tamil021.ttf");
normalTypeface = Typeface.createFromAsset(getAssets(), "fonts/NOVASOLID ___.ttf");
}

public View getView(int position, View convertView, ViewGroup parrent) {
View row = convertView;

if (row == null) {
LayoutInflater inflater = getLayoutInflater();

row = inflater.inflate(R.layout.row, parrent, false); // inflate view from xml file
}

//Below two textView

TextView tamil = (TextView) row.findViewById(R.id.tamil);
tamil.setText(FRUITS[0][position] + " - ");
tamil.setTypeface(tamilTypeface);

TextView normal = (TextView) row.findViewById(R.id.normal);
normal.setText(FRUITS[1][position]);
normal.setTypeface(normalTypeface);

return row;
}


}

}


this is code modified for creating an search box

package com.WidgetActivity;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class WidgetActivity extends Activity {

private static final String[][] listview_array = {
{"ஆப்பிள்", "அவோகாடோ", "பாணன்"},{"Durian", "Guava", "Kiwifruit"}
};
int textlength=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


ListView listView = new ListView(this);; //just simple ListView
listView.setAdapter(new MyAdapter()); //MyAdapter is private class that extends ArrayAdapter where I can create my own view

setContentView(listView); // here we put view and set them
}

private class MyAdapter extends ArrayAdapter {
private Typeface tamilTypeface, normalTypeface;

public MyAdapter() {
super(WidgetActivity.this, R.layout.row, FRUITS); //super class constructor

tamilTypeface = Typeface.createFromAsset(getAssets(), "fonts/TABUni-Tamil021.ttf");
normalTypeface = Typeface.createFromAsset(getAssets(), "fonts/NOVASOLID ___.ttf");
}

public View getView(int position, View convertView, ViewGroup parrent) {
View row = convertView;

if (row == null) {
LayoutInflater inflater = getLayoutInflater();

row = inflater.inflate(R.layout.row, parrent, false); // inflate view from xml file
}

//Below two textView

TextView tamil = (TextView) row.findViewById(R.id.tamil);
tamil.setText( listview_array[0][position] + " - ");
tamil.setTypeface(tamilTypeface);

TextView normal = (TextView) row.findViewById(R.id.normal);
normal.setText( listview_array[1][position]);
normal.setTypeface(normalTypeface);

return row;
}


lv = (ListView) findViewById(R.id.ListView01);
et = (EditText) findViewById(R.id.EditText01);
lv.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, listview_array));

et.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s)
{
// Abstract Method of TextWatcher Interface.
}
public void beforeTextChanged(CharSequence s,
int start, int count, int after)
{
// Abstract Method of TextWatcher Interface.
}
public void onTextChanged(CharSequence s,
int start, int before, int count)
{
textlength = et.getText().length();
array_sort.clear();
for (int i = 0; i < listview_array.length; i++)
{
if (textlength <= listview_array[i].length())
{
if(et.getText().toString().equalsIgnoreCase(
(String)
listview_array[i].subSequence(0,
textlength)))
{
array_sort.add(listview_array[i]);
}
}
}
lv.setAdapter(new ArrayAdapter<String>
(ListViewSearchExample.this,
android.R.layout.simple_list_item_1, array_sort));
}
});
}

}

can any one tell how to introduce an search box for giving an query?
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to create an search box for this code ?

package com.Activity;

import android.app.Activity;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

public class MyActivity extends Activity {

String[] itemsArray = {"ஆப்பிள்", "அவோகாடோ", "பாணன்"};
//private static final String[][] FRUITS = { {"ஆப்பிள்", "அவோகாடோ", "பாணன்"},{"Durian", "Guava", "Kiwifruit"} };
private EditText _etText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


ListView listView = new ListView(this);; //just simple ListView
listView.setAdapter(new MyAdapter()); //MyAdapter is private class that extends ArrayAdapter where I can create my own view

setContentView(listView); // here we put view and set them
}

private class MyAdapter extends ArrayAdapter {
private Typeface tamilTypeface, normalTypeface;

public MyAdapter() {
super(MyActivity.this, R.layout.row, itemsArray); //super class constructor

tamilTypeface = Typeface.createFromAsset(getAssets(), "fonts/TABUni-Tamil021.ttf");
normalTypeface = Typeface.createFromAsset(getAssets(), "fonts/NOVASOLID ___.ttf");
//tamilTypeface = Typeface.createFromAsset(getAssets(), "fonts/tamil1.ttf");

// normalTypef ace = Typeface.createFromAsset(getAssets(), "fonts/normal1.ttf");
}

Context context;

// String[] itemsArray = { "SUN","MON", "TUS", "WED", "THU", "FRI", "SAT"};


public int getCount() {
// TODO Auto-generated method stub
return itemsArray.length;
}

public Object getItem(int position) {
// TODO Auto-generated method stub
return itemsArray[position];
}

public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}



public View getView(int position, View convertView, ViewGroup parrent) {
View row = convertView;

if (row == null) {
LayoutInflater inflater = getLayoutInflater();

row = inflater.inflate(R.layout.row, parrent, false); // inflate view from xml file
}

//Below two textView

TextView tamil = (TextView) row.findViewById(R.id.tamil);
tamil.setText((itemsArray[position]));
tamil.setTypeface(tamilTypeface);


/*
TextView normal = (TextView) row.findViewById(R.id.normal);
normal.setText(FRUITS[1][position]);
normal.setTypeface(normalTypeface);
*/
return row;
}


}


}

can any one help me ?
 
Poop goes in a willow feeder. Wipe with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic