开发者

What do I do to make the TextView (address+postcode) clickable & to open google maps?

<?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"> 

<TextView 
android:id="@+id/address" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:autoLink="map" /> 

<TextView 
android:id="@+i开发者_高级运维d/postcode" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:autoLink="map" /> 

<ListView 
android:id="@android:id/list" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"/> 

</LinearLayout> 


Its very simple...

Just add onCLickListener on to the TextView.. in the function dont directly call the map activity. but instaed firstly change the color of textview. and then using Handler call postDelayed Method to call the Map Activity to have clicking effect

check the code below

Handler mHandler = new Handler();
final TextView myTextView = (TextView)findViewById(R.id.TextView01);
myTextView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {


        // TODO Auto-generated method stub

                           myTextView.setTextColor(Color.red);
                           mHandler.postDelayed(new Runnable(){

                                public void run()
                                {
                                   // Here call your map activity
                                }  
                             },200L); 
        }
    });

Hope this will help :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜