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

by » 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, "" <>


Sponsored Links

Other Threads

1. debugging integrated Java and native code


I am trying to figure out what is the best way to debug a mix of Java 
and native code? Please notice, that I am NOT trying to develop a native 
app. The app will be written entirely in Java, using Android SDK. 
However, I noticed that some pieces of the SDK use native methods (e.g. 
AssetManager, WebKit, etc). I wonder which tools Google developers use 
if/when they need to debug a mix of Java and C/C++ code? Eclipse/gdb or 
there are commercial tools which make the debugging experience less painful?

I googled on this topic and the results returned do not look very 



2. Writing files to SD card failing

Hi there,

I'm writing an podcast playing application.  The application has pre-
defined feeds but I want to cache the image of the feed for 30 days.
However, on the initial creation of the podcast I am downloading the
image, and trying to save it to the SD card using the code below:

public long createPodcast(RssFeed feed, String feedUrl) {
        ContentValues insertValues = new ContentValues();
        insertValues.put(KEY_FEED_TITLE, feed.title);
        insertValues.put(KEY_FEED_FEED_URL, feedUrl);
        insertValues.put(KEY_FEED_DESCRIPTION, feed.description);
        insertValues.put(KEY_FEED_PUBDATE, feed.pubDate);
        insertValues.put(KEY_FEED_IMAGE_URL, feed.imageUrl);
        insertValues.put(KEY_FEED_IMAGE_WIDTH, feed.imageWidth);
        insertValues.put(KEY_FEED_IMAGE_HEIGHT, feed.imageHeight);
        insertValues.put(KEY_FEED_SUBSCRIBED, false);

        long rowId = mDb.insert(TABLE_PODCAST_LIST, null,

        String storage_state = Environment.getExternalStorageState
        if (storage_state.contains("mounted")) {
                File f = Environment.getExternalStorageDirectory();
                File j = new File(f, "twitcast");
                try {
                                URL users_avatar = new URL(feed.imageUrl);
                                HttpURLConnection conn = (HttpURLConnection)
                                InputStream is = conn.getInputStream();
                                Bitmap bmImg = BitmapFactory.decodeStream(is);

                                File k = new File(j, rowId + ".jpg");
                                FileOutputStream fos = new FileOutputStream(k);
                                bmImg.compress(Bitmap.CompressFormat.JPEG, 100, 
                        } catch (IOException e) {
                                // TODO Auto-generated catch block
        return rowId;

However, it keeps failing on the line k.createNewFile(); with the
WARN/System.err(10727): Parent of file is not a
directory: /sdcard/twitcast/1.jpg

I've checked and I have write permission and the SD card is mounted,
and I have android.permission.MOUNT_UNMOUNT_FILESYSTEMS included in my

Does anyone have any ideas why this keeps failing?

Tane Piper


3. WebView-Security/Privacy

4. Pygame on Android

5. Sensors: Does orientation depend on acceleration?

6. "Native code is not supported in the current SDK."

7. how to obtain asset file uri