Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Start an new Activity Intent with a parameter Android example

putString(), putBoolean(), putInt() etc.¨
How we can start an activity programmatically.

// MainActivity.java
//  myButton.setOnClickListener
Intent binary = new Intent(getApplicationContext(),Calculate.class);
	Bundle b = new Bundle();
	b.putString("prvni_label", "Decimal");
	b.putString("druhy_label", "Binary");
	b.putString("mode", "binary_to_decimal");
	startActivityForResult(binary, 0);
// in Calculate.java onCreate

   TextView mTextView1 = (TextView)findViewById(R.id.textView1);
   TextView mTextView2 = (TextView)findViewById(R.id.textView2);    
     Bundle _bundle = getIntent().getExtras();

//.................. HOW OPEN START NEW ACTIVITY WITHOUT A PARAMETER .........................

startActivity(new Intent(ThisActivity.this, NewActivity.class));

397LW NO topic_id

Další témata ....(Topics)


Eclipse ADT plugin not recent graphical layout editor | eclipse-adt-plugin-not-recent-graphical-layout-editor

Click to Android version combobox - drop down menu and select your version, which just using (have instaled). For example: You updated ADT by SDK manager, but forget to update Android version. You can use lower version from drop down menu, which using your project, or do update of Android by SDK manager.

long in java example | long-in-java-example

Android development

long is 64 bit signed type and used when int is not large enough to hold the value.

long je celé číslo 64 bitů -9223372036854775808 +9223372036854775807 a používá se tam, kde typ int není schopen pojmout takovou hodnotu čísla.

		// declaration and assignment of value type long
		long n = 22337203685477580L;
		// print formated value
		System.out.printf("The value of x is %d%n", n); // 22337203685477580
		System.out.format("%+,8d%n%n", n); // +22 337 203 685 477 580

		// declaring more variables in single statement
		long lo1 = 12L, lo2 = 56, lo3 = 1455555555589L;

		// long range of value
		System.out.println(Long.MAX_VALUE); // 9223372036854775807
		System.out.println(Long.MIN_VALUE); // -9223372036854775808

		// check if a string is a valid number in Java example
		// convert string to long Java example
		String sLong = "1288888888888888";
		long longParse = Long.parseLong(sLong);

		// convert strings to numbers
		long longFromString = (Long.valueOf(sLong)).longValue();

		// long to string in Java example code
		Long longObj = new Long(229999999999L);
		String str = longObj.toString();
		// else
		Long longS = 888888888888L;
		String strLong = longS.toString();

		// compare two long variables
		Long longComp1 = 5555L;
		if (longComp1.equals(55555555L))

		// compares the two specified long values in Java example

		int i = longS.compareTo(444444L); // -1 first < second
		// 0 first == second
		// 1 first > second

Links too close together Mobile friendly page | links-too-close-together-mobile-friendly-page

Try set bigger line-height of links and font size for example:

/*in css*/
line-height: 48px;
font-size: 20px;
background-color: rgb(255,204,0);

/* in html page set class of link*/
<a class="links" href="m.mydomen.com/mypage.html">Blah blah mypage</a>

// or in css for all links on page
a {
line-height: 48px;
font-size: 20px;

/*html page*/
<a href="m.mydomen.com/mypage.html">Blah blah mypage</a>


Saving Activity state int String Array Double on Android | saving-activity-state-int-string-array-double-on-android

private int[] mData = new int[2]; // fill some values into array!!
    protected void onSaveInstanceState(Bundle outState) {
        outState.putBoolean("myBoolean", true);
        outState.putDouble("myDouble", 2.7);
        outState.putInt("myInt", 5);
        outState.putString("myString", "Heloo girls!");
       int[] data = new int[mData.length];
        for (int i = 0; i < data.length; i++) {
            data[i] = mData[i];
        outState.putIntArray("myArray", data);

public void onRestoreInstanceState(Bundle savedInstanceState) {
  boolean myBoolean = savedInstanceState.getBoolean("myBoolean", false); // false basic value
  double myDouble = savedInstanceState.getDouble("myDouble", 1.5); // 1.5 basic value
  int myInt = savedInstanceState.getInt("myInt", 10);
  String myString = savedInstanceState.getString("myString", "Hello boys!");
  int[] data = savedInstanceState.getIntArray("myArray");
  if (data != null && data.length == mData.length) {
            for (int i = 0; i < data.length; i++) {
                mData[i] = data[i];
public void onCreate(Bundle savedInstanceState) {
  boolean myBoolean =  savedInstanceState != null ? savedInstanceState.getBoolean("myBoolean", false) : true;
// etc.  .......


Linkify text link url in TextView text Android example | linkify-text-link-url-in-textview-text-android-example

Example from SDK C:\Program Files\Android\android-sdk-windows\samples\android-10\ApiDemos\src\com\example\android\apis\text\Link.java
Source: //developer.android.com/resources/browser.html?tag=sample
License: //www.apache.org/licenses/LICENSE-2.0
1.) Automatically linkifies using android:autoLink="all"

// res/values/strings.xml
<string name="link_text_auto"><b>text1:</b> This is some text.  In
      this text are some things that are actionable.  For instance,
      you can click on //www.google.com and it will launch the
      web browser.  You can click on google.com too.  And, if you
      click on (415) 555-1212 it should dial the phone.
// main.xml
<!-- text1 automatically linkifies things like URLs and phone numbers. -->
  <TextView xmlns:android="//schemas.android.com/apk/res/android"

2.) Link text by setMovementMethod

// MainActivity.java onCreate
/*Be warned that if you want a TextView with a key listener or movement method not to be focusable, or if you want a TextView without a key listener or movement method to be focusable, you must call setFocusable(boolean) again after calling this to get the focusability back the way you want it. */

TextView t2 = (TextView) findViewById(R.id.text2);

// main.xml
<!-- text2 uses a string resource containing explicit <a> tags to
       specify links. -->
  <TextView xmlns:android="//schemas.android.com/apk/res/android"


<string name="link_text_manual"><b>text2:</b> This is some other
      text, with a <a href="//www.google.com">link</a> specified
      via an <a> tag.  Use a \"tel:\" URL
      to <a href="tel:4155551212">dial a phone number</a>.

3.) Link as html code using Html.fromHtml()

// MainActivity.java onCreate
        TextView t3 = (TextView) findViewById(R.id.text3);
                "<b>text3:</b>  Text with a " +
                "<a href=\"//www.google.com\">link</a> " +
                "created in the Java source code using HTML."));

4.) Link string by SpannableString

        SpannableString ss = new SpannableString(
            "text4: Click here to dial the phone.");

        ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 6,
        ss.setSpan(new URLSpan("tel:4155551212"), 13, 17,

        TextView t4 = (TextView) findViewById(R.id.text4);

linkify link url adress text in Android

Editace Jana Žákovská : 2013-01-27 22:37:38
Počet článků v kategorii: 397