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 Arc Android basic example

drawArc(), Canvas, Paint, 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(5);
			// opacity
			//p.setAlpha(0x80); //
 
			RectF rectF = new RectF(50, 20, 100, 80);
			canvas.drawOval(rectF, p);
			p.setColor(Color.BLACK);
			canvas.drawArc (rectF, 90, 45, true, p);
		}

	}
}


396LW NO topic_id




AD

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


292

Java Basic Rules | java-basic-rules



// file name MyFirstClass.java

import java.util.*;
import java.lang.Math;
import java.io.*;
import javax.swing.*;

public class MyFirstClass{ // start of program
  public static void main(String[] args) { // basic  function main

// variables and calculation
int a=2;
int b=3;
int c=Integer.parseInt(JOptionPane.showInputDialog(" Put number: ", "1"));
System.out.println("Number is: "+c);
System.out.println(a+" * "+b+" = "+(a*b));
System.out.println("a^3 "+Math.pow(a,b));

//array
int[] array_my=new int[10];
array_my[0]=3;
array_my[1]=5;
System.out.println("Number of elements "+array_my.length+" 1 + 2 element of array "+(array_my[0]+array_my[1]));

//strings
String txt="Quick red fox";
String txt2=JOptionPane.showInputDialog("Write text: ", "word");
System.out.println("Text is: "+txt2);
String[] count_of_word=txt.split(" ");
System.out.println("Length: "+txt.length()+" Count of words "+count_of_word.length);
System.out.println(txt +" -> "+txt.replace("red","brown"));
System.out.println("First 5 chars of string is: "+ txt.substring(0,5));

//for a if
for(int i=0; i<10;i++){
	if(i==3)System.out.println("i equal "+i);
	}

// file
try {
  File soubor=new File("some_file.txt");
  if(!soubor.exists()){
	System.out.println("File dont exist");
  }
  else { // utf-8 encoding
    BufferedReader in1 = new BufferedReader(new InputStreamReader(new FileInputStream(soubor),"UTF-8"));
    BufferedWriter out1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("zapis.txt"),"UTF-8"));
    String str;
      while ((str = in1.readLine())!=null){
        System.out.println(str);
        out1.write(str+"

"); } in1.close(); out1.close(); } } catch(IOException e){System.out.println("Error " + e);} // dir File pathName = new File("some_dir"); String[] fileNames = pathName.list(); if(pathName.exists()) System.out.println("Name of first file in "some_dir": "+fileNames[0]); else System.out.println("dir not exist"); //function int nResult = calculateMyFc(3,5); System.out.println("Result of function: "+nResult); } // end of function main // new function , you can add to end MyFc = my function public static int calculateMyFc(int a, int b){ return (a+b); } } // end of class of program
103

Android RadioGroup alignment like TableLayout | android-radiogroup-alignment-like-tablelayout


xml example source code with image.


   <TableLayout android:layout_width="match_parent" android:id="@+id/idTableInRadioGroup" android:layout_height="wrap_content">
        <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">


<RadioGroup android:id="@+id/idRadio_group_1_column"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:orientation="vertical">
 <RadioButton android:id="@+id/idRadio_1"
                android:text="@string/textLabel_1"/>
            <RadioButton android:id="@+id/idRadio_2"
                android:text="@string/textLabel_2"/>
            <RadioButton android:id="@+id/idRadio_3"
                android:text="@string/textLabel_3"/> 
 
        </RadioGroup>
<RadioGroup android:id="@+id/idRadio_group_2_column"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:orientation="vertical">
 
  <RadioButton android:id="@+id/idRadio_4"
                android:text="@string/textLabel_4"/>
            <RadioButton android:id="@+id/idRadio_5"
                android:text="@string/textLabel_5"/>
            <RadioButton android:id="@+id/idRadio_6"
                android:text="@string/textLabel_6"/>
        </RadioGroup>
</TableRow>        
    </TableLayout>



android/two-column-menu.png
270

How to add or remove widgets home screen android 4 | how-to-add-or-remove-widgets-home-screen-android-4


Video tutorial
How to add or remove widgets home screen Android 4.