Breaking News
Home / Android / Android Snippets (page 5)

Android Snippets

How to get button text on click in Android?

The following code shows how to associated the OnClickListener with the button and later on when its clicked and that handler is invoked how to get the title to the button. Button buttonAdvert = (Button) findViewById(R.id.button_advert);                CharSequence text = “Hello”;        buttonAdvert.setText(text);         buttonAdvert.setOnClickListener(new View.OnClickListener() {    …

Read More »

How to send Email via Intent in Android?

Snippet The following snippet shows how to send Email via an Email Intent in an Android Activity. package com.livrona.apps.radio.activity;   import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ImageButton;   import com.livrona.andriod.commons.utils.Log;   public class AboutScreen extends Activity {    @Override  public void onCreate(Bundle savedInstanceState) {      Log.d("in …

Read More »

How to implement Button OnClickListener in Android?

Snippet The following snippet shows how to implement OnClickListner for a ImageButton in an Android Activity. package com.livrona.apps.radio.activity;   import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ImageButton;   import com.livrona.andriod.commons.utils.Log;   public class AboutScreen extends Activity {           @Override         public …

Read More »

How do you encode url in Android?

Snippet Encoding URL is very straightforward, simply call the encode method of the URLEncoder class on the String data that you want to encode. try {     String url = "http://www.yoursite.com/blah";   String queryString = "param=1&value=2";       String encodedQueryString = URLEncoder.encode(queryString,"UTF-8");      encodedUrl = url + …

Read More »
Advertisment ad adsense adlogger