How to determine the amount of characters that will fit into a TextView

by nwmotog...@gmail.com » Fri, 10 Apr 2009 06:11:55 GMT


Sponsored Links
 I am trying to place only the exact amount of data into a TextView but
I need to know how much it can hold.  Is there a way to do this based
on it's height, width and the textsize?
--~--~---------~--~----~------------~-------~--~----~



How to determine the amount of characters that will fit into a TextView

by nEx.Software » Fri, 10 Apr 2009 21:05:25 GMT


 I'd say if you know the text you want to put into the TextView, you
should be able to measure the text and compare to the size of the
TextView... In the API Demos, there is a measure text sample. I'd
start there.

On Apr 9, 3:11pm, "nwmotog...@gmail.com" <nwmotog...@gmail.com>


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. How to add a refresh button to a webview app?

Hey guys, i'm very new to this. I only have basic XHTML knowledge and
im looking into getting more into android development so ive been
reading the tutorials but i cant find a tutorial on how to create a
menu and then make the menu button refresh my webview content.
anyone...here's my current code. i was wondering if someone could show
me how it should look to make it when i hit the menu button and then
how to make the menu button do a refresh of my web content. thanks in
advance i think getting to look how it is done may help me understand
a lot of whats been confusing me ive looked everywhere and i just get
lost.

*****************************
my code:
webview.java -
*****************************
package com.brybam.webview;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class webview extends Activity {
        /** Called when the activity is first created. */
        WebView webview;
        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        webview = (WebView) findViewById(R.id.webview);
        webview.setWebViewClient(new webviewClient());
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl("http://google.com");
    }
        private class webviewClient extends WebViewClient {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view,
String url)
{
                view.loadUrl(url);
                return true;
            }
        }
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack
()) {
                webview.goBack();
                return true;
            }
            return super.onKeyDown(keyCode, event);
        }
}


*****************************
main.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">
    <WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />

</LinearLayout>


*****************************
AndroidManifest.xml -
*****************************
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.brybam.webview"
      android:versionName="3" android:versionCode="3">
    <application android:icon="@drawable/icon"
android:theme="@android:style/Theme.NoTitleBar">
        <activity android:name=".webview"
                  android:label="@string/app_name"
                  android:configChanges="keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>





-- 

2. Connect Android to Android or PC

Hi,

 I am trying to do a little game for android, but I wanted several
players to play using a PC and another phone.
 How can I send and rreceive information from other phones or PCs?
 I really just want to know my possibilities, can I do it through
HTTP? Is there a better way if I know which PC to connect to?

Thank you,
duarte

-- 

3. Which sdk / emulator vers for moto cliq ?

4. Text file

5. Android development with ADK in Eclipse on Snow Leopard

6. colored logcat for windows

7. Android 2.0 sample codes