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.

Difference between “@+id/” and “@id/” in Android



Difference between "@+id/” and "@id/” in Android
android:id="@+id/xxx" unique identifier of view
@id/ a reference to the unique identifier

 <TextView
        android:id="@+id/first_element_id"
        .........
 />
    <TextView
        android:id="@+id/second_element_id"
        android:layout_below="@id/first_element_id"
        ..........
 />


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);            
    	}
    	
    }




14

SQLite explorer download | sqlite-explorer-download


Best of SQLite explorer and admin download for SQLite 2.x and SQLite 3.x in separated folders.

Download Explorers SQLite 2.x and SQLite 3.x in separated folders
349

Android Google Maps Night Mode | android-google-maps-night-mode


If you want save battery, select "Satelite map" from map menu and reduce the brightness of the display.

android-google-maps-night-mode-as-satelite-map.jpg
51

Get assets folder files to array of strings Android example | get-assets-folder-files-to-array-of-strings-android-example


Get assets folder files to array of strings.
Its show files in assets folder and sub folders:


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        final AssetManager assetManager = getAssets();
        try {
			// for assets folder add empty string
                        String[] filelist = assetManager.list("");
                        // for assets/subFolderInAssets add only subfolder name
                        String[] filelistInSubfolder = assetManager.list("subFolderInAssets");
			if (filelist == null) {
			    // dir does not exist or is not a directory
			} else {
			    for (int i=0; i<filelist.length; i++) {
			        // Get filename of file or directory
			        String filename = filelist[i];
			    }
			}
                     
                        // if(filelistInSubfolder == null) ............  

		} catch (IOException e) {
			e.printStackTrace();
		}
     }


42

Scroll to certain position on application Android example code | scroll-to-certain-position-on-application-android-example-code


ScrollTo(), getTop(), getBottom(), getLeft(), getRight(), ScrollView, LinearLayout Android Java xml example.
How get position of a View.
MainClass.java

/*
public void scrollTo (int x, int y) 
Since: API Level 1 
Set the scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated. 

This version also clamps the scrolling to the bounds of our child.

Parameters
x  the x position to scroll to 
y  the y position to scroll to  
  */

// sroll to top of hscrollViewMain
ScrollView hscrollViewMain = (ScrollView)findViewById(R.id.scrollViewMain);
hscrollViewMain.scrollTo(0, 0); // scroll to application top

// get position of a View
EditText hEdit = (EditText)findViewById(R.id.username_edit);
int nY_Pos = hEdit.getTop(); // getBottom(); X_pos  getLeft(); getRight();
// scroll to top of hEdit
hscrollViewMain.scrollTo(0,nY_Pos); 


main.xml


<LinearLayout
    xmlns:android="//schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <ScrollView
        android:id="@*id/scrollViewMain"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1">
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical"
            android:paddingTop="5dip"
            android:paddingBottom="13dip"
            android:paddingLeft="20dip"
            android:paddingRight="20dip">
            <TextView
                android:id="@+id/message"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dip" />
            <TextView
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textStyle="bold"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/login_activity_username_label" />
            <EditText
                android:id="@+id/username_edit"
                android:singleLine="true"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:minWidth="250dip"
                android:scrollHorizontally="true"
                android:capitalize="none"
                android:autoText="false"
                android:inputType="textEmailAddress" />
        </LinearLayout>
    </ScrollView>

</LinearLayout>


Editace Jana Žákovská : 2015-12-01 11:31:06
Počet článků v kategorii: 397
Url:difference-between-id-and-id-in-android
Share
Share
Tweet