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.

Importing google-play-service library project to workspace issue


AD MOB

Try two way in Eclipse IDE:

1.) Import the library project into your Eclipse workspace.
Click File > Import,
select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
If project not visible with checkbox try next step as see below.

2.) Click
File > New > Other
select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.

397LW NO topic_id




AD

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


61

Get text file content from raw folder to StringBuilder Android example | get-text-file-content-from-raw-folder-to-stringbuilder-android-example


StringBuilder, res/raw folder, try catch finaly throws, BufferedReader, InputStream, openRawResource, getResources Android example

MainActivity.java


public class MainActivity extends Activity {
TextView txtV;
	Context cntx;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        txtV = (TextView)findViewById(R.id.idLabel);
        cntx = this;
        try {
			StringBuilder strBuilder = myFunction(cntx);
			txtV.setText(strBuilder);
		} catch (IOException e) {
			e.printStackTrace();
		}

        
    }
    
    
    private StringBuilder myFunction(Context context) throws IOException {
        final Resources resources =  context.getResources();
        InputStream inputStream = resources.openRawResource(R.raw.my_file);
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder strBuild = new StringBuilder();
        try {
            String line;
            while ((line = reader.readLine()) != null) {
            	strBuild.append(line);
            }
        } finally {
            reader.close();
        }
       return strBuild; 
       
    }
}

230

Eclipse Log.e println needs a message | eclipse-log-e-println-needs-a-message


Log.e println needs a message error.
E/AndroidRuntime(330): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{b.paint/b.paint.MainActivity}: java.lang.NullPointerException: println needs a message

Try this code:

		// Error
                String s = null;
		Log.e("bla", s); // !!! error Log.e println needs a message error.
                // OK
		String s = null;
		Log.e("bla", s+""); // OK 


254

Spinner Text Size Android Example | spinner-text-size-android-example



      Spinner  _spin1 = (Spinner) findViewById(R.id.spinLangFirst);
      ArrayAdapter<String> adapterJazyky = new ArrayAdapter<String>(this,
              R.layout.spinner_text_layout.xml, {"one","two","etc...."});
      adapterJazyky.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      _spin1.setAdapter(adapterJazyky);





spinner_text_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="//schemas.android.com/apk/res/android"
          android:id="@+id/spinnerText"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
         
         android:textSize="20sp"
/>
146

Rotate a image bitmap picture Android example | rotate-a-image-bitmap-android-example


Rotate a bitmap Android source code.

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) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.YELLOW);
            
          // Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
			
		    //  you need to insert a image flower_blue into res/drawable folder 
			Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.flower_blue);
			 Matrix mat = new Matrix();
			                mat.postRotate(90);
			                Bitmap bmpRotate = Bitmap.createBitmap(bmp, 0, 0,
			  bmp.getWidth(), bmp.getHeight(),
			  mat, true);
		   int h = bmp.getHeight();
           
           canvas.drawBitmap(bmp, 10,10, paint);
           canvas.drawBitmap(bmpRotate, 10,10 + h + 10, paint);
           
		}

	}
}




rotate bitmap android
117

AlertDialog yes no - Alert - Messagebox - Android sample | alertdialog-yes-no-alert-messagebox-android-sample


Dialog Yes No sample code

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit application?")
       .setCancelable(false)
       .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                MyActivity.this.finish(); //Close  this Activity for example: MyActivity.java
           }
       })
       .setNegativeButton("No", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                // some code if you want
                dialog.cancel();
           }
       });
AlertDialog alert = builder.create();
alert.show();


Editace: 2014-09-10 16:52:48
Počet článků v kategorii: 397
Url:importing-google-play-service-library-project-to-workspace-issue

AD
11 Share
Share
Tweet