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.

Difference between logical operators and or Java


AD MOB

Basic difference remember it!!!
if(TRUE && TRUE && TRUE) return TRUE otherwise FALSE

if(FALSE || FALSE || FALSE) return FALSE otherwise TRUE

Logical operator and &&
If all conditions/operands is TRUE return TRUE, otherwise return FALSE

if( true and true and true){ 
  // return true - do something
}
int a = 6;
if(a == 6 && a == 6 ) {
 // if TRUE
 // true && true return true, do something
}

if(a == 6 && a == 5){
  // nothing, not attended
}else{
  // true && false return false, or false && false return false 
  // do something
}


Logical operator or ||
The logical OR operator (||) returns the boolean value true if either or both operands is true and returns false otherwise.
If one operands is TRUE, condition is TRUE:

if(FALSE OR FALSE OR TRUE) return TRUE
if(FALSE OR TRUE OR FALSE) return TRUE
if(FALSE OR FALSE OR FALSE) return FALSE

int a = 6;
if(a==6 || a==5){ // TRUE || FALSE return TRUE
  //if return TRUE
  //one from operadns is TRUE return true,  do something
}

if(a==5 || a==4){ // FALSE || FALSE return FALSE
 // not attended
}else{
 //if return FALSE, do something
}

rev

397LW NO topic_id




AD

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


200

Samsung i9250 Galaxy Nexus | samsung-i9250-galaxy-nexus






























Brand Samsung
Model (codename) i9250 Galaxy Nexus
Cena, včetně DPH 9000
Veikost Displaye v palcích 4.65
Display-resolution 1280x720
Dotek-typ kapacitní
CPU typ
CPU MHz 1200
CPU core 2
L2 cache
RAM 1 GB
ROM 16 - 32 GB
GPU TI OMAP 4460 1,2 GHz dual-core
NenaMark2 Benchmark
GPU-GLBenchmark
Baterie mAh 1750
Foto MPx 5
Autofocus yes
Video 480p - 30 frames/s
Official Android ICS Android 4.0 Ice Cream Sandwich
CyanogenMod support
Dotek-prstů-max
Display-ppi
Display-retina
Network GSM&EDGE: 850 / 900 / 1.800 / 1.900
Connectivity
Pozn.


samsung-i9250-galaxy-nexus image
samsung-i9250-galaxy-nexus
38

TableRow TableLayout table row add delete remove removeview addview Android example | tablerow-tablelayout-table-row-add-delete-remove-removeview-addview-android-example


TableRow TableLayout table row add delete remove removeview addview get table row index indexOfChild create table row dynamically TextView dynamically Android example
Main.java

TableLayout table = (TableLayout)findViewById(R.id.table);
TableRow row = (TableRow)findViewById(R.id.row);

// get table row index android.
int nIndex = table.indexOfChild(row);
table.removeView(row); // invisible and height == 0
// add row into same place 
table.addView(row, nIndex); // visible

// add row into certain position
table.addView(row, 3); // visible

// create new TableRow dynamically 
TableRow tr = new TableRow(this);
         tr.setLayoutParams(new LayoutParams(
                        LayoutParams.FILL_PARENT,
                        LayoutParams.WRAP_CONTENT));

// create own function for append TableRow
   private void appendRow(TableLayout table) {
        TableRow row = new TableRow(this);

        TextView hLabel = new TextView(this);
        hLabel.setText("Some text");
        hLabel.setPadding(3, 3, 3, 3);

        TextView hNextLabel = new TextView(this);
        hNextLabel.setText("Next text");
        hNextLabel.setPadding(3, 3, 3, 3);
        hNextLabel.setGravity(Gravity.RIGHT | Gravity.TOP);

        row.addView(hLabel, new TableRow.LayoutParams(1));
        row.addView(hNextLabel, new TableRow.LayoutParams());

        table.addView(row, new TableLayout.LayoutParams());
    }



main.xml ScrollView, TableLayout, TableRow, TextView Android xml layout example

<ScrollView xmlns:android="//schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    <TableLayout
                android:id="@+id/table"
                  android:layout_width="fill_parent"
                 android:layout_height="fill_parent">
        <TableRow>
            <TextView android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Row index 0"/>
        </TableRow>
        <TableRow android:id="@+id/row">
            <TextView android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Row index 1"/>
        </TableRow>
        <TableRow>
            <TextView android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Row index 2"/>
        </TableRow>
        <TableRow>
            <TextView android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Row index 3"/>
        </TableRow>
		</TableLayout>
</ScrollView>

220

Full Screen No title Android | full-screen-no-title-android


Full Screen without titlebar and statusbar for Android Activity.
In Activity.java

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }

or in AndroidManifest.xml

<activity android:name=".ActivityName"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>

184

Transparent Background Android example | transparent-background-android-example


android:background="@android:color/transparent"

<LinearLayout
    android:baselineAligned="false"
    android:background="@android:color/transparent"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
   >
<LinearLayout>
////////////////////////////
LinearLayout  mLinearLayout1 = (LinearLayout)findViewById(R.id.linearLayout1);
mLinearLayout1.setBackgroundColor(Color.TRANSPARENT);

147

Resize a bitmap image Android example | resize-a-bitmap-image-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.YELLOW);
            
	         
	         paint.setFilterBitmap(true);
	         Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.flower_blue);
	         int targetWidth  = bitmapOrg.getWidth() * 2;
	         int targetHeight = bitmapOrg.getHeight() * 2;
	         Bitmap bmp = Bitmap.createBitmap(targetWidth, targetHeight,Bitmap.Config.ARGB_8888);
	         RectF rectf = new RectF(0, 0, targetWidth, targetHeight);
	         Canvas c = new Canvas(bmp);
	         Path path = new Path();
	         path.addRect(rectf, Path.Direction.CW);
	         c.clipPath(path);
	         c.drawBitmap( bitmapOrg, new Rect(0, 0, bitmapOrg.getWidth(), bitmapOrg.getHeight()),
	                         new Rect(0, 0, targetWidth, targetHeight), paint);
	         Matrix matrix = new Matrix();
	         matrix.postScale(1f, 1f);
	         Bitmap resizedBitmap = Bitmap.createBitmap(bmp, 0, 0, targetWidth, targetHeight, matrix, true);
	         int h = bitmapOrg.getHeight();
           canvas.drawBitmap(bitmapOrg, 10,10, paint);
           canvas.drawBitmap(resizedBitmap, 10,10 + h + 10, paint);
           
		}

	}
}


resize bitmap android


Editace: 2016-02-29 17:06:05
Počet článků v kategorii: 397
Url:difference-between-logical-operators-and-or-java

AD
11 Share
Share
Tweet