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.

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

397LW NO topic_id



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


260

Delete Bitmap Android Example | delete-bitmap-android-example


If some memory leak - problem try release of memory used of a big Bitmap what already not to need;
Bitmpap bmp; // not null
bmp.recycle();
bmp = null;

final boolean bmpIsRecycled = bmp.isRecycled()
// Returns true if this bitmap has been recycled.


//developer.android.com/reference/android/graphics/Bitmap.html
Free the native object associated with this bitmap, and clear the reference to the pixel data. This will not free the pixel data synchronously; it simply allows it to be garbage collected if there are no other references. The bitmap is marked as "dead”, meaning it will throw an exception if getPixels() or setPixels() is called, and will draw nothing. This operation cannot be reversed, so it should only be called if you are sure there are no further uses for the bitmap. This is an advanced call, and normally need not be called, since the normal GC process will free up this memory when there are no more references to this bitmap.
2

Click Handler | click-handler-android-code


Click Handler Android Java example source code. Open new class as activity and open URL in browser.
In layout.xml file:



In string.xml

myClickHandler



In MainClass.java file

	public void myClickHandler(View view) {
		switch (view.getId()) {
		// open new class as activity
		case R.id.btnOpenClass: {
				Intent pictureActivity = new Intent(getBaseContext(),
						MyClass.class);
				startActivity(pictureActivity);
		}
		break;			
			
		case R.id.btnAbout: {
			//aboutDialogCreate();
		}
			break;
			
		// open url	
		 case R.id.btnHome: {
		 String url = "//android.okhelp.cz/";
		 Intent i = new Intent(Intent.ACTION_VIEW);
		 i.setData(Uri.parse(url));
		 startActivity(i);
		 }break;

		}

	}// end myClickHandler

// listener .. if click on button will scrolling to mTextView bottom
private OnClickListener mButtonListener = new OnClickListener() {
	    public void onClick(View v) {
	      // do something when the button is clicked
	    int nBottom =	mTextView.getBottom();
	    hScrollView.scrollTo(0, nBottom);
	    }
	};

78

Goto labeled statement in Java example | goto-labeled-statement-in-java-example


Goto in for cycle Java example source code.
MainClass.java

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = {"nothing", "Hello", "people"
				, "bye-bye", "hello", "world!", "end" };
		
	    OuterLoop: for (int i = 0;i<6; i++) {
	        for (int j = 0; j < arrayOfString.length; j++) {
	        	if (arrayOfString[j].equals("world!")) {
	            continue OuterLoop; // as goto from Csharp, or C/C++
	          }
	          System.out.println(arrayOfString[j]);
	          System.out.println(i);
	          if (i == 1) {
	        	  System.out.println("break");
	        	  
	        	  break OuterLoop;
	          }
	        }
	      }
		
	}
}
/*
nothing
0
Hello
0
people
0
bye-bye
0
hello
0
nothing
1
break
*/
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();
}


23

Hide keyboard Android example | hide-keyboard-android-example


Use this code for example in some method or function

// public Object getSystemService (String name)
// Return the handle to a system-level service by name.
// The class of the returned object varies by the requested name.
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
//public boolean hideSoftInputFromWindow (IBinder windowToken, int flags)
//EditText myEdit = (EditText)findViewById(R.id.idEditText);
inputMethodManager .hideSoftInputFromWindow(myEdit.getWindowToken(), 0);




Editace: 2011-10-14 20:03:29
Počet článků v kategorii: 397
Url:android-radiogroup-alignment-like-tablelayout
Share
Share
Tweet