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.

Eclipse revert old version Android Development Tools


AD MOB

If you have trouble with compilation of new project after you make a update of android development tools you can go back to old version of the tools.




    • Open Help > About Eclipse... use the menu > About...

    • Click the "Installation Details" button.

    • Select the "Installation History" tab.

    • Select one of the previous configurations.

    • Click the "Revert" button at the bottom.





eclipse-revert-android-development-tools-1

eclipse-revert-android-development-tools-2



397LW NO topic_id




AD

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


99

Essential Eclipse Shortcuts with pictures | essential-eclipse-shortcuts-with-pictures


Eclipse Navigation Shortcuts.

Keyboard_shortcuts_(3.0).pdf
Ctrl+1 Quick fix problem
eclipse-ctrl-1



Ctrl+O Quick Outline
eclipse-ctrl-o



Ctrl+Shift+G Find references in workspace
Ctrl+Shift+U Find all references in file
eclipse-ctrl-shift-u




Ctrl+Shift+T Find Java Typ

[caption id="attachment_1214" align="alignleft" width="150" caption="eclipse-ctrl-shift-t"][/caption]


Ctrl+Shift+R Find Resource



Ctrl+E Open Editor Drop-Down
Ctrl+Space Content Assist
eclipse-ctrl-space


Ctrl+Shift+Space Context Information

eclipse-ctrl-shift-space


F3 Open Declaration of variable
F4 Open Type Hierarchy
Ctrl+H Open Search Dialog
Alt+Shift+R Rename - Refactoring
Alt+Shift+M Extract Method
Alt+Shift+L Extract Local Variable

Alt Shift Up Expand selection to enclosing element
Alt Shift Right Expand selection to next element
Alt Shift Left Expand selection to previous element
Alt Shift Down Restore previous selection

Breakpoints Shift+Alt+Q B
Cheat Sheets Shift+Alt+Q H
Console Shift+Alt+Q C
Java Declaration Shift+Alt+Q D
Java Package Explorer Shift+Alt+Q P
Java Type Hierarchy Shift+Alt+Q T
Javadoc Shift+Alt+Q J
Search Shift+Alt+Q S
Show View (View: Outline)Shift+Alt+Q O
Show View (View: Problems)Shift+Alt+Q X
Synchronize Shift+Alt+Q Y
Variables Shift+Alt+Q V

140

Create Bitmap with Linear Gradient Android example | create-bitmap-with-linear-gradient-android-example



public class ApokusActivity 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) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);
            
            Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
             paint.setColor(Color.BLUE);
            
            Shader mShader = new LinearGradient(0, 0, 100, 70, new int[] {
                    Color.RED, Color.GREEN, Color.BLUE },
                    null, Shader.TileMode.MIRROR);  // CLAMP MIRROR REPEAT
            Canvas c = new Canvas(b);
            paint.setShader(mShader);
            //c.drawCircle(60, 60, 30, paint);
            c.drawRect(0, 0, 200, 200, paint);
            canvas.drawBitmap(b, 10,10, paint);
		}

	}
}


linear gradient bitmap android example
4

Read file from URL | read-file-from-url


Read file from URL to array of byte and convert to UTF-8 String Android examle source code.

URL urlLoc = new URL("//myweb.com/myfile.html");
URLConnection conexion = urlLoc.openConnection();
conexion.setConnectTimeout(4000);
conexion.setReadTimeout(1000);
conexion.connect();

// downlod the file
InputStream input = new BufferedInputStream(urlLoc
		.openStream());

StringBuffer responseBuffer = new StringBuffer();
byte[] byteArray = new byte[1024];
while (input.read(byteArray) != -1)
 {   
        String res = new String(byteArray, "UTF-8");
        responseBuffer.append(res);
        byteArray = null;
        byteArray = new byte[1024];
 }

String response = responseBuffer.toString().trim();



369

ClassCastException fragments.MainActivity must implement OnHeadlineSelectedListener | classcastexception-fragments-mainactivity-must-implement-onheadlineselectedlistener


Problem:
You have two class with similar names HeadLinesFragment and HeadMyLinesFragment with OnHeadlineSelectedListener.
Check if call correct class in MainActivity.
For example if use HeadMyLinesFragment change implement to HeadMyLinesFragment too!


public class MainActivity extends FragmentActivity 
        implements HeadLinesFragment.OnHeadlineSelectedListener { 
// wrong implements you need correct class name 
//implements  HeadMyLinesFragment.OnHeadlineSelectedListener
//............
HeadMyLinesFragment firstFragment = new HeadMyLinesFragment(); // because in code using HeadMyLinesFragment

240

AsyncTask Example Android with ProgressBar | asynctask-example-android-with-progressbar


MainActivity.java

package com.asynctaskexample;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MainActivity extends Activity {
	private TextView textView;
	private ProgressBar progressBar;
	private DownloadWebPageTask mTask = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		textView = (TextView) findViewById(R.id.TextView01);
		downloadPage();
	}

	// AsyncTask <TypeOfVarArgParams , ProgressValue , ResultValue> .
	private class DownloadWebPageTask extends AsyncTask<String, Integer, String> {

		@Override
		protected void onPreExecute() {
			//textView.setText("Hello !!!");
			progressBar = (ProgressBar) findViewById(R.id.progressBar1);
			progressBar.setVisibility(View.VISIBLE);
			super.onPreExecute();
		}

		@Override
		protected void onProgressUpdate(Integer... values) {
			super.onProgressUpdate(values);

		}

		@Override
		protected String doInBackground(String... urls) {
			String response = "";
			for (String url : urls) {
				DefaultHttpClient client = new DefaultHttpClient();
				HttpGet httpGet = new HttpGet(url);
				try {
					HttpResponse execute = client.execute(httpGet);
					InputStream content = execute.getEntity().getContent();

					BufferedReader buffer = new BufferedReader(new InputStreamReader(
							content));
					String s = "";
					while ((s = buffer.readLine()) != null) {
						response += s;
					}

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return response;
		}

		@Override
		protected void onPostExecute(String result) {
			progressBar.setVisibility(View.INVISIBLE);
			textView.setText(result);
		}
	}

	private void downloadPage() {
		if (mTask != null
				&& mTask.getStatus() != DownloadWebPageTask.Status.FINISHED) {
			mTask.cancel(true);
		}
               // execute(String[]) you can put array of links to web pages, or array of Integer[] 
               // if first param is Integer[] etc.
		mTask = (DownloadWebPageTask) new DownloadWebPageTask()
				.execute(new String[] { "//android.okhelp.cz/android-market.html",
						"//android.okhelp.cz/android-market.html" });
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();

		if (mTask != null
				&& mTask.getStatus() != DownloadWebPageTask.Status.FINISHED) {
			mTask.cancel(true);
			mTask = null;
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}




activity_main.xml

<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/TextView01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</LinearLayout>



AndroidManifest.xml do not forget INTERNET uses-permission !!!!!!!

<uses-permission android:name="android.permission.INTERNET" />



Editace: 2014-02-15 20:22:18
Počet článků v kategorii: 397
Url:eclipse-revert-old-version-android-development-tools

AD
11 Share
Share
Tweet