Category: Snippets
Java: WebView
//Add the below line into your AndroidManifest.xml file or your app will not have internet access. <uses-permission android:name=”android.permission.INTERNET”/> import android.webkit.WebView; import android.webkit.WebViewClient; final WebView wv = (WebView) findViewById(R.id.myWebView); //The below line tells the system that it must use your WebView to load URLs. //Otherwise when you click a link within your WebView it android will […]
Java: Change text in TextView and date
import android.widget.TextView; final TextView tv = (TextView)findViewById(R.id.txtInfo); tv.setText(“You just changed the text”); //to extend this lets update the TextView with the date import java.util.Date; final String currentDateTimeString = java.text.DateFormat.getDateTimeInstance().format(new Date()); tv.setText(currentDateTimeString);
Java: Button Listener
import android.widget.Button; Button button = (Button) findViewById(R.id.btnChangeText); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { //Do somethimg here } });