Okhelp.cz

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.

Linkify TextView clickable phone number url adress



android:autoLink="all"

 <!-- text1 automatically linkifies things like URLs and phone numbers. -->
  <TextView
            android:id="@+id/text1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:autoLink="all"
            android:text="@string/link_text_auto"
            />

397LW NO topic_id



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


53

Timer stopwatch based on Java Calendar class Android example | timer-stopwatch-java-calendar-android-example


Start Stop Stopwatch Timer Android example source code.


private static long mStartTime = 0L;
Calendar cal;
TextView hTextViewVypis = (TextView)findViewById(R.id.idTextVypis);

void start(){
            cal = Calendar.getInstance();
            mStartTime = cal.getTimeInMillis();
}

void stop(){
     prinOutStopWatchTime();
}


    private void prinOutStopWatchTime() {
    	final long start = mStartTime;
    	
    	cal = Calendar.getInstance();
    	long stopTime = cal.getTimeInMillis();
    	long millis = stopTime - start;
    	long milisekundy = millis % 1000;
    	int seconds = (int) (millis / 1000);
    	int minutes = seconds / 60;
    	seconds     = seconds % 60;
    	int hour = minutes / 60;
    	hour = hour % 60;
    	
    	if (seconds < 10) {
    		hTextViewVypis.setText(hour +  ":" + minutes + ":0" + seconds + ":" + milisekundy);
    	} else {
    		hTextViewVypis.setText(hour  +  ":" + minutes + ":" + seconds + ":" + milisekundy);            
    	}
    	
    }




25

Copy sqlite database from apk package to device folder Android example | copy-sqlite-database-from-apk-to-device-folder-android-example


Put your sglite database to Android Eclipse project folder named Assets.
On device will copy database file to application folder as this example:



 public void createDatabase(Context myContext) throws IOException {
    String sPackName = myContext.getPackageName();
    InputStream assetsDB = myContext.getAssets().open("myDatabase");
    OutputStream dbOut = new FileOutputStream("/data/data/"+sPackName+"/database");
 
    byte[] buffer = new byte[1024];
    int length;
    while ((length = assetsDB.read(buffer))>0){
      dbOut.write(buffer, 0, length);
    }
 
    dbOut.flush();
    dbOut.close();
    assetsDB.close();
}


337

IllegalArgumentException Unknown Uri content SearchableDict | illegalargumentexception-unknown-uri-content-searchabledict


If you change the package name, you have to add new package name in:

DictionaryProvider.java


public class DictionaryProvider extends ContentProvider {
    String TAG = "DictionaryProvider";

//    public static String AUTHORITY = "com.example.android.searchabledict.DictionaryProvider";
// change to your new package name
public static String AUTHORITY = "com.myweb.mysubdomen.searchabledict.DictionaryProvider";
    public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/dictionary");


// in AndroidManifest.xml
//change com.example.android to your package e.g. com.myweb.mysubdomen
<!-- Provides search suggestions for words and their definitions. -->
        <provider android:name="com.example.android.searchabledict.DictionaryProvider"
            android:configChanges="keyboard|keyboardHidden|orientation"
                  android:authorities="com.example.android.searchabledict.DictionaryProvider" />

        <!-- Points to searchable activity so the whole app can invoke search. -->
        <meta-data android:name="android.app.default_searchable"
            android:configChanges="keyboard|keyboardHidden|orientation"
                   android:value=".SearchableDictionary" />

// I change like this:
        <!-- Provides search suggestions for words and their definitions. -->
        <provider android:name=".DictionaryProvider"
            android:configChanges="keyboard|keyboardHidden|orientation"
                  android:authorities="cz.okhelp.android.searchabledict.DictionaryProvider" />

        <!-- Points to searchable activity so the whole app can invoke search. -->
        <meta-data android:name="android.app.default_searchable"
            android:configChanges="keyboard|keyboardHidden|orientation"
                   android:value=".SearchableDictionary" />


Do not forget change package name in all java class and xml/searchable.xml
In my project I changed like this:

<searchable xmlns:android="//schemas.android.com/apk/res/android"
        android:label="@string/search_label"
        android:hint="@string/search_hint"
        android:searchSettingsDescription="@string/settings_description"
        android:searchSuggestAuthority="cz.okhelp.android.searchabledict.DictionaryProvider"
        android:searchSuggestIntentAction="android.intent.action.VIEW"
        android:searchSuggestIntentData="content://cz.okhelp.android.searchabledict.DictionaryProvider/dictionary"
        android:searchSuggestSelection=" ?"
        android:searchSuggestThreshold="1"
        android:includeInGlobalSearch="true"
        >
 </searchable>


103

Android RadioGroup alignment like TableLayout | android-radiogroup-alignment-like-tablelayout


xml example source code with image.


   <TableLayout android:layout_width="match_parent" android:id="@+id/idTableInRadioGroup" android:layout_height="wrap_content">
        <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">


<RadioGroup android:id="@+id/idRadio_group_1_column"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:orientation="vertical">
 <RadioButton android:id="@+id/idRadio_1"
                android:text="@string/textLabel_1"/>
            <RadioButton android:id="@+id/idRadio_2"
                android:text="@string/textLabel_2"/>
            <RadioButton android:id="@+id/idRadio_3"
                android:text="@string/textLabel_3"/> 
 
        </RadioGroup>
<RadioGroup android:id="@+id/idRadio_group_2_column"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:orientation="vertical">
 
  <RadioButton android:id="@+id/idRadio_4"
                android:text="@string/textLabel_4"/>
            <RadioButton android:id="@+id/idRadio_5"
                android:text="@string/textLabel_5"/>
            <RadioButton android:id="@+id/idRadio_6"
                android:text="@string/textLabel_6"/>
        </RadioGroup>
</TableRow>        
    </TableLayout>



two-column-radiogroup-menu
21

How to install mount SD card for Eclipse Android Emulator | how-install-sd-card-on-android-eclipse-emulator


If you want download some *.apk file from internet and try on your emulator you get error than you have to install SD card. You have to closing Android emulator.
Mount Android emulator SD card instruction

  1. In Eclipse go in menu Window - Android SDK and Avg Manager

  2. Select Virtual devices

  3. Select AVD Name where you need install SD card

  4. Click on Edit button

  5. In open dialog go to SD card - Size: and write 500

  6. Press button Edit AVD

  7. Run AVD emulator


Image how install SD card on Android emulator in Eclipse.




Editace Jana Žákovská : 2015-11-08 10:47:25
Počet článků v kategorii: 397
Url:linkify-textview-clickable-phone-number-url-adress
Share
Share
Tweet