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.

Draw circle Android basic example



Canvas, drawCircle(), Paint, onDraw(), 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.drawCircle(50, 50, 30, p);
		}

	}
}


397LW NO topic_id



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


191

Invalid proguard configuration file path Android Eclipse Error | invalid-proguard-configuration-file-path-android-eclipse-error


Invalid proguard configuration file path
C:\documents\my_android_projects\my_project\proguard.cfg does not exist or is not a regular file

Solution:
Check if exist file proguard.cfg in your project on the path C:\docum.........
If not exist, copy a file proguard.cfg from other project or create file proguard.cfg and insert
this source code to file and save this file.



-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}



From more details see:
//developer.android.com/guide/developing/tools/proguard.html
312

Windows set Environment Variables - Java path | windows-set-environment-variables-java-path


How set JAVA path to Environment Variables on Windows (7)
Select Start menu > Computer > System Properties > Advanced System Settings(properties).
Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for example

 C:\Program Files\Java\jdk1.8.0_05
350

Cannot resolve symbol HttpGet,HttpClient,HttpResponce in Android Studio | cannot-resolve-symbol-httpgethttpclienthttpresponce-in-android-studio


Try this code:

final String ERROR = "my error message....";

 private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
// some code and method ..... see AsyncTask

       @Override
        protected String doInBackground(String... urls) {

              URL urlL = null;
                try {
                    urlL = new URL(url);//"//chmi.cz..../"
                    HttpURLConnection urlConnection = null;
                    try {
                         urlConnection = (HttpURLConnection) urlL.openConnection();
                        InputStream in = new BufferedInputStream(urlConnection.getInputStream());
                      response =  readStream(in);
                        return response;
                    } catch (IOException e) {
                        //throw new RuntimeException(e);

                    } finally {
                        if(urlConnection != null)
                            urlConnection.disconnect();
                        return ERROR;
                    }
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                    return ERROR;
                }
           }
            return response;
        }

        private String readStream(InputStream is) {
            try {
                ByteArrayOutputStream bo = new ByteArrayOutputStream();
                int i = is.read();
                while(i != -1) {
                    bo.write(i);
                    i = is.read();
                }
                return bo.toString();
            } catch (IOException e) {
                return "";
            }
        }

341

ActivityThread: Failed to find provider Sqlite database | activitythread-failed-to-find-provider-sqlite-database


Issue:
ActivityThread: Failed to find provider

Try check this authority tags if they are all the same:
(com.yourdomen.yourproject.YourContentProviderClass replace your path to YourContentProviderClass)

res/xml/serchable.xml
Tag searchable

<searchable xmlns:android="//schemas.android.com/apk/res/android"
android:blahblah 
......
android:searchSuggestAuthority="com.yourdomen.yourproject.YourContentProviderClass"


AndroidManifest.xml
Tag provider

 <provider android:name=".YourContentProviderClass"
                  android:authorities="com.yourdomen.yourproject.YourContentProviderClass" />

276

Eclipse Error parsing the sdk Android | eclipse-error-parsing-the-sdk-android


[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Error parsing the sdk.
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Failed to create C:\Program Files\android\sdk\add-ons.
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Unable to parse SDK content.

You have to create add-ons folder as admin of PC


Editace Jana Žákovská : 2013-12-09 13:11:26
Počet článků v kategorii: 397
Url:draw-circle-android-basic-example
Share
Share
Tweet