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.

Drawable Bitmap get width height Android




		Drawable dr = getResources().getDrawable(R.drawable.algebra);
		int h = dr.getIntrinsicHeight();
		int w = dr.getIntrinsicWidth();

		Bitmap ball = BitmapFactory.decodeResource(getResources(), R.drawable.algebra);
		int _nWidth = ball.getWidth();
		int _nHeight = ball.getHeight();



397LW NO topic_id



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


90

Map TreeMap get values to array Java Android example | map-treemap-get-values-to-array-java-android-example



import java.util.Map;
import java.util.TreeMap;

public class MainClass {
	public static void main(String[] arg) {

		// english;germany dictionary
		String[] arrayOfString = { "one;eine", "two;zwei", "two sets of;zwei"
				, "three;drei", "four;vier" };

		Map<String, String> map = new TreeMap<String, String>();

		for (String s : arrayOfString) {
			String[] array = s.split(";");
			String sKey = "", sValue = "";
			if (array.length > 1) {
				sKey = array[0];
				sValue = array[1];
				map.put(sKey, sValue);
			}
		}
    Object[] objectArrayOfValues = map.values().toArray();
	for (int i = 0; i < objectArrayOfValues.length; i++) {
		System.out.println(objectArrayOfValues[i]);
	}
		 
		
	}// end main

}
/*
vier
eine
drei
zwei
zwei
 */
22

RadioButton RadioGroup Java Android example | radiobutton-radiogroup-android-example


RadioButton RadioGroup Android example source code for Android developer
Example for *.xml files

       <RadioGroup android:id="@+id/idRadio_group"
            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>



Example for *.java files

// import
import android.widget.RadioGroup;
// get handle of RadioGroup
RadioGroup  mRadioGroup = (RadioGroup) findViewById(R.id.idRadio_group);

// which RadioButton is selected for example in some function body
         int nUnits = 10; // decimetry
    	 int nIdRadio = mRadioGroup.getCheckedRadioButtonId();
    			if(nIdRadio == R.id.idRadio_1) nUnits = 1; // metr
    			else if(nIdRadio == R.id.idRadio_2) nUnits = 10; // decimetr
    			else if(nIdRadio == R.id.idRadio_3) nUnits = 100; // cm
    			else if(nIdRadio == R.id.idRadio_4) nUnits = 1000; // mm


// listener for RadioGroup Java Android example
       mRadioGroup.setOnCheckedChangeListener(
                new RadioGroup.OnCheckedChangeListener() {
                    public void onCheckedChanged(RadioGroup group,
                            int checkedId) {
                        Log.v("Selected", "New radio item selected: " + checkedId);
                        recordNewUIState();
                    }
                });



235

ACRA allows your Android application to send Crash Reports | acra-allows-your-android-application-to-send-crash-reports


ACRA allows your Android application to send Crash Reports to various destinations:

a Google Docs spreadsheet (default and original behavior)
an email
your own server-side HTTP POST script
any other possible destination by implementing your own report sender

ACRA wiki and download page of project library
43

No title bar Android application without titlebar style Theme NoTitleBar Android example | no-title-bar-android-application-without-titlebar-style-theme-notitlebar-android-example


Set in AndroidManifest.xml android:theme="@android:style/Theme.NoTitleBar" AndroidManifest.xml example source code.
AndroidManifest.xml


<manifest xmlns:android="//schemas.android.com/apk/res/android"
    package="com.myexample.without_titlebar">
    <application android:label="My app">
      <activity android:name="NoTitleBar"
        android:theme="@android:style/Theme.NoTitleBar"
        android:screenOrientation="portrait"
        android:configChanges="keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

134

Draw Oval Android basic example | draw-oval-android-basic-example


drawOval(), setStrokeWidth(), setStyle()


public class MainActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}

		@Override
		protected void onDraw(Canvas canvas) {

			canvas.drawColor(Color.CYAN);
			Paint p = new Paint();
			// smooths
			p.setAntiAlias(true);
			p.setColor(Color.RED);
			p.setStyle(Paint.Style.STROKE); 
			p.setStrokeWidth(4.5f);
			// opacity
			//p.setAlpha(0x80); //
 
			canvas.drawOval(new RectF(50, 50, 20, 40), p);;
		}

	}
}


Editace Jana Žákovská : 2013-12-09 13:01:23
Počet článků v kategorii: 397
Url:drawable-bitmap-get-width-height-android
Share
Share
Tweet