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.

ADT Bundle 22.6.2 have memory leak.



If I trying
android-sdk_r22.6.2-windows.zip
adt-bundle-windows-x86_64-20140321.zip
and open xml layout graphic editor and xml layout file
memory continues to grow to crashes Eclipse

https://developer.android.com/sdk/index.html

I have to install old version adt-bundle-windows-x86-20131030.zip
what working fine.
I had to delete .metadata folder in workspace if I want open old version ADT

397LW NO topic_id



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


347

Pixel to density independent pixel to pixel conversion | pixel-to-density-independent-pixel-to-pixel-conversion


Physical pixel (px)
Density independent pixel (dp)
Dots per inch (dpi) .. physical pixels per inch
px = dp * (dpi / 160)

public static int dpToPx(int dp)
{
    return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}

public static int pxToDp(int px)
{
    return (int) (px / Resources.getSystem().getDisplayMetrics().density);
}
125

Get SensorManager PowerManager WindowManager Display Android example | get-sensormanager-powermanager-windowmanager-display-android-example



    private SensorManager mSensorManager;
    private PowerManager mPowerManager;
    private WindowManager mWindowManager;
    private Display mDisplay;

// onCreate
   @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

       // Get an instance of the SensorManager
        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

        // Get an instance of the PowerManager
        mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);

        // Get an instance of the WindowManager
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        mDisplay = mWindowManager.getDefaultDisplay();

        setContentView(R.layout.main); // main.xml or your xml file name

}

33

Spinner ComboBox DropDown List Android example code | spinner-combobox-dropdown-list-android-code-example


Spinner in Android application is equivalent of ComboBox in WinApi.
Spinner get selected item to string example.
Spinner get selected item position to int example.

Main activity class MainComboBox.java

public class MainComboBox extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Spinner spinner = (Spinner) findViewById(R.id.spinner);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.countries_array, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());

        Button myButton =(Button)findViewById(R.id.button1);
        myButton.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
            	
            Spinner sp =	(Spinner)findViewById(R.id.spinner);
            String spinnerString = null;
            spinnerString = sp.getSelectedItem().toString();
            int nPos = sp.getSelectedItemPosition();
            
             
                Toast.makeText(getApplicationContext(), "getSelectedItem=" + spinnerString,
                    Toast.LENGTH_LONG).show();
                Toast.makeText(getApplicationContext(), "getSelectedItemPosition=" + nPos,
                		Toast.LENGTH_LONG).show();
            }
        });
    }
}



File MyOnItemSelectedListener.java

public  class MyOnItemSelectedListener implements OnItemSelectedListener {

    public void onItemSelected(AdapterView<?> parent,
        View view, int pos, long id) {
      Toast.makeText(parent.getContext(), "Item is " +
          parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
    }

    public void onNothingSelected(AdapterView parent) {
      // Do nothing.
    }
}


strings.xml

<resources>
    <string name="hello">Hello World, MainComboBox!</string>
    <string name="app_name">ComboBox</string>
    <string name="prompt">Choose a country</string>
    <string-array name="countries_array">
        <item>China</item>
        <item>India</item>
        <item>USA</item>
        <item>Indonesia</item>
        <item>Brazil</item>
        <item>Pakistan</item>
        <item>Nigeria</item>
        <item>Bangladesh</item>
        <item>Russia</item>
    </string-array>    
</resources>


main.xml

<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:padding="10dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="@string/prompt"
    />
    <Spinner 
        android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:prompt="@string/prompt"
    />
    <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

</LinearLayout>




210

Zipalign ADT Eclipse | zipalign-adt-eclipse


Zipalign.exe path on Windows:
c:\Program Files\Android\android-sdk-windows\tools\zipalign.exe

zipalign [-f] [-v] <alignment> infile.apk outfile.apk

// command line in Total Commander
zipalign.exe -f -v 4 infile.apk outfile.apk

When using Eclipse with the ADT plugin, the Export Wizard will automatically zipalign your .apk after it signs it with your private key.


How do signs .apk with your private key - image:


signs-apk-with-eclipse-android-1

signs-apk-with-eclipse-android-1

signs-apk-with-eclipse-android-1

signs-apk-with-eclipse-android-1

signs-apk-with-eclipse-android-1

More about Zipalign android.com
223

Delete Canvas - Fill Canvas Android example | delete-canvas-fill-canvas-android-example


Fill the entire canvas with the specified color.

@Override
    public void onDraw(Canvas canvas) {
    canvas.drawColor(Color.GREEN);
}


Editace Jana Žákovská : 2014-04-03 08:49:37
Počet článků v kategorii: 397
Url:adt-bundle-22-6-2-have-memory-leak
Share
Share
Tweet