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.

Open url with browser if button clicked Android example.


AD MOB

Button, setOnClickListener, Intent.ACTION_VIEW, startActivity Android example.


Button mIdButtonHome = (Button)findViewById(R.id.idButtonHome);
	mIdButtonHome.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Intent browserIntent = new Intent(
					Intent.ACTION_VIEW,
					Uri.parse("//android.okhelp.cz/category/software/"));
			startActivity(browserIntent);
		}
	});



397LW NO topic_id




AD

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


363

How rebuild only one module in project Android Studio | how-rebuild-only-one-module-in-project-android-studio


If you do click on Rebuid project menu item, this operation maybe consume long time on slovly PC.
Some errors dismis when you do rebuild project, or module.
Try this:
Select module where contains red error code and press Debugg or Run button on Android Studio.
If module code contains errors, Android Studio show error report in gradle console.
If not, apk will installed on device.
This is 10 times faster than Clean - Rebuild all project.
246

Set Custom Font to View Android Example | set-custom-font-to-view-android-example


You have to put your font fonts/samplefont.ttf into assets/fonts folder in your project!

// set own custom font from assets
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface mFace = Typeface.createFromAsset(getContext().getAssets(),
                                             "fonts/samplefont.ttf");
    txt.setTypeface(mFace);
392

Histogram foto picture smartphone | histogram-foto-picture-smartphone


Very dark picture, in photo editor black remains black
histogram-picture-very-black colored

Very bright picture, in photo editor white will white
histogram-picture-very-bright-picture

Dark picture but the chart is not in black color area - dark shades can be lighten in graphics editor
histogram-picture-diagram
138

Draw text drawText Android basic example | draw-text-drawtext-android-basic-example


drawText(), setColor(), setTextSize(), setTextAlign()

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();
			
            paint.setColor(Color.YELLOW);
            paint.setTextSize(60);
            //paint.setTextAlign(Paint.Align.CENTER);

            canvas.drawText("Hello world!", 0, 50, paint);
		}

	}
}

79

ArrayList Collections Add new Item Sort Find Item Java example | arraylist-collection-sort-add-java-example


How add item to ArrayList, sort ArrayList, search find index of item in ArrayList, min(), max() Java basic example.

import java.util.ArrayList;
import java.util.Collections;

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = {"nothing", "Hello", "people"
				, "bye-bye", "hello", "world!", "End" };
		   ArrayList<String> arrayList = new ArrayList<String>();
            for(String s: arrayOfString)
		     arrayList.add(s);

		    Collections.sort(arrayList);
		    // foreach
		    for (String str: arrayList)
		      System.out.println(str);
		    
		    Object objMin = Collections.min(arrayList);
		    System.out.println("Min is: " + objMin);
		    
		    Object objMax = Collections.max(arrayList);
		    System.out.println("Max is: " + objMax);
		    
		    int index = Collections.binarySearch(arrayList, "people");
		    System.out.println("Index of people is: " + index);
		    
		  }

		
	
}
/*
End
Hello
bye-bye
hello
nothing
people
world!
Min is: End
Max is: world!
Index of people is: 5
*/


Editace: 2011-10-05 14:14:41
Počet článků v kategorii: 397
Url:open-url-with-browser-if-button-clicked-android-example

AD
11 Share
Share
Tweet