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.

Two boolean as one parameter value in function Java


AD MOB


boolean fc(boolean b) {
	return b;
}// end fc
		boolean bA = true;
		boolean bB = true;
		boolean bC = bA || bB; // true

		bA = true;
		bB = false;
		bC = bA || bB; // true

		bA = false;
		bB = true;
		bC = bA || bB; // true

		bA = false;
		bB = false;
		bC = bA || bB; // false
		
			if(!fc(bB||bA))
			System.out.println("false"); // false
                        else 
			System.out.println("true"); 



397LW NO topic_id




AD

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


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" />

296

On orientation changed view button textview not visible Android | on-orientation-changed-view-button-textview-not-visible-android


Try add to AndroidManifest.xml configChanges for your Activity
android:configChanges="keyboardHidden|orientation|screenSize"


 <activity android:name=".MainActivity"
                  android:label="@string/app_name"
                  android:configChanges="keyboardHidden|orientation|screenSize"
                  >
248

Resize ImageView Image in View Android Example | resize-imageview-image-in-view-android-example


How to resize an image in ImageView Android source code.
Resize imageview layout and image will resize too:

	public void resizeImageView(int width, int height) {
		final ImageView picture1 = (ImageView)findViewById(R.id.imageView1);
		LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height);
		picture1.setLayoutParams(layoutParams);
	}

6

Show keyboard | show-keyboard


Show keyboard Android phone apps development example source code.

// ActivityClass.java
InputMethodManager showSoftInput;
Button hBtnKeyboardShow ;
//onCreate
showSoftInput = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE);

hBtnKeyboardShow = (Button)findViewById(R.id.btnKeyboardShow);
hBtnKeyboardShow.setOnClickListener(myButtonListener);
// END onCreate

//button listener
private OnClickListener myButtonListener = new OnClickListener() {
     public void onClick(View v) {
     	 try {
     		 showSoftInput.getInputMethodList();
                 showSoftInput.toggleSoftInput(showSoftInput.SHOW_FORCED, 0);	
		} catch (Exception e) {
			Log.e("Keyboard show ", e.getMessage());
			
		}
     }
};


215

How to programmatically set the button style - Android | how-to-programmatically-set-the-button-style-android


How set rounded corners and own styles ActivityMy.java

Button btn.setBackgroundResource(R.drawable.back_button_answer);



\res\drawable\back_button_answer.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="//schemas.android.com/apk/res/android" android:shape="rectangle" >
   <corners android:radius="10dip" />
   <!-- background -->
   
   <gradient
                android:startColor="#D6D7D6"
                android:centerColor="#E2E2E2"
                android:centerY="0.75"
                android:endColor="#D6D7D6"
                android:angle="270"
        />
   
   <stroke android:width="2dip" android:color="#fff"/>
</shape>


Editace: 2013-02-04 20:29:14
Počet článků v kategorii: 397
Url:two-boolean-as-one-parameter-value-in-function-java

AD
11 Share
Share
Tweet