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 emulator freezes at startup create new virtual device


AD MOB

If Android emulator freezes at startup, try create new virtual device with smaller memory and cpu usage, or select older version of Android, or buy new pc with higher performance.

  1. open AVD MANAGER

  2. press Create Virtual Device

  3. select Device with small memory usage (e.g. 480x800 of resolution) - Next

  4. check - Show downloadable ....

  5. Download - lower version of system Android, select, press - Next

  6. check data, Show Advanced Settings, check Use host... and press Finish


android-studio-create-virtual-device-emulator

397LW NO topic_id




AD

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


281

addPreferencesFromResource Deprecated Android Code Warning | addpreferencesfromresource-deprecated-android-code-warning


Put extends PreferenceFragment API level 11 instead PreferenceActivity

public class SettingsActivity extends PreferenceFragment {
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.preferences);
  }
}

// or insert suppresswarning
public class SettingsActivity extends PreferenceActivity {
  @SuppressWarnings("deprecation")
	@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.preferences);
  }
}

44

No resource found that matches the given name Eclipse Android xml file | no-resource-found-that-matches-the-given-name-eclipse-android-xml-file


No resource found that matches the given name - error examples.
Exist resource file?
Is code written correctly?

// No resource found that matches the given name (at id with value @id/myButton).
 android:id="@id/myButton" // invalid id notation
 android:id="@+id/myButton" // correct


 // No resource found that matches the given name 
// (at icon with value @drawable/icons).
// exist file icons in res/drawable folder?
<application android:icon="@drawable/icons" 

//No resource found that matches the given name 
//(at theme with value @style/MyThem).
<activity android:name=".Main"
                  android:label="@string/app_name"
                  android:theme="@style/MyThem">

// Exist style MyThem  in styles.xml ?  No only MyTheme
<style name="MyTheme" parent="android:Theme">
        <item name="android:windowTitleSize">50px</item>
</style>



// exist file my_background in folder drawable ?
android:background="@drawable/my_background" // 

// no resource found that matches the given name(at "label" with value "@string/app_name")
// have you the string resource defined in res/values/strings.xml ?
<string name="app_name">"My App"</string>


156

Convert Drawable to Bitmap to Drawable | converts-drawable-to-bitmap



Context context = getApplicationContext();
Drawable drawable = context.getResources().getDrawable(R.drawable.my_image);
// convert drawable to bitmap
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
// convert bitmap to drawable
Drawable d = new BitmapDrawable(bitmap);

Android example source code.
173

Custom View Android Basic Example | custom-view-android-basic-example


Activity.java

public class A extends Activity{
	Bitmap bm;
	 TouchImageView touch;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		 setContentView(R.layout.main);
		 
		 bm = BitmapFactory.decodeResource(getResources(), R.drawable.chinese_sky_map);
 		 touch =  (TouchImageView)findViewById(R.id.myImageView);
	  touch.setImageBitmap(bm);
		 
	}
}


\res\layout\main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <cz.okhelp.TouchImageView.TouchImageView
        android:id="@+id/myImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        
        />

</LinearLayout>



location TouchImageView\src\cz\okhelp\TouchImageView\TouchImageView.java

public class TouchImageView extends ImageView {


    Context context;

// constructor wihtout using  *.xml file
//    public TouchImageView(Context context) {
//        super(context);
// }

// constructor with xml file
    public TouchImageView(Context context, AttributeSet attrs)
    {
      super(context, attrs);
      super.setClickable(true);
        this.context = context;
  }
}

213

Round number float - double to int - long Java example | round-number-float-to-int-java-example



int nf = Math.round(5.789f);
System.out.print(nf); // 6

float f = 28.611f; 
int n3 = Math.round(f);
System.out.println(n3); // 29

double d = 1234.56;
long lon = Math.round(d);
System.out.println(lon); // 1235

int diff = 90 - 40;
// float fDeleni = diff / 10; // error code
float fDeleni = (float)diff / 10.f; // ok
int nRound = Math.round(fDeleni);


// Caution:
int n2 = (int) 8.999f;
System.out.println(n2); // 8




Editace: 2015-11-08 10:49:52
Počet článků v kategorii: 397
Url:android-emulator-freezes-at-startup-create-new-virtual-device

AD
11 Share
Share
Tweet