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.

How set gray text to EditText Android example


AD MOB

Example source code for Android development. How set gray text to EditText when EditText is blank.
Hint text to display when the text is empty.
In layout/main.xml insert to EditText row Attribute Name android:hint="Some text"


<EditText
        android:id="@+id/myEdit" 
	android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:hint="Some text"
	android:singleLine="true"
</EditText>	



Programatically you can use method setHint:


// setHint(CharSequence hint) example
(EditText)findViewById(R.id.myEdit).setHint("My text");
// or int resId as method setHint(int resId) 
EditText myEdit = findViewById(R.id.myEdit);
myEdit.setHint(R.string.app_name);




397LW NO topic_id




AD

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


233

ACRA allows your Android application to send Crash Reports | acra-allows-your-android-application-to-send-crash-reports


ACRA allows your Android application to send Crash Reports to various destinations:

a Google Docs spreadsheet (default and original behavior)
an email
your own server-side HTTP POST script
any other possible destination by implementing your own report sender

ACRA wiki and download page of project library
191

configChanges value of the com.google.ads.AdActivity must include | configchanges-value-of-the-com-google-ads-adactivity-must-include


Errors:
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
E/Ads(333): You must have AdActivity declared in AndroidManifest.xml with configChanges.

Solution:
Try to using a lower version of the GoogleAdMobAdsSDK ADS SDK in project:
GoogleAdMobAdsSDK-4.0.4
How add SDK to project

Add activity to AndroidManifest.xml


// .............. blah
    <uses-sdk android:minSdkVersion="4"/>
   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application android:icon="@drawable/dicts_ico" android:label="@string/app_name" 
    >
           <meta-data 
        android:value="a12345_your_number" 
        android:name="ADMOB_PUBLISHER_ID" />
        <activity android:name=".MainStartMenu"
                  android:label="@string/app_name"
                  android:configChanges="keyboardHidden|orientation"
                  >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


  <!-- Google ads -->      
<activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation"/>

// ......... blah 
185

Get the color of a specific pixel Java Android example | get-the-color-of-a-specific-pixel-java-android-example



             ImputStream      is = this.getResources().openRawResource(R.drawable.colors);
             Bitmap    mBitmap2 = BitmapFactory.decodeStream(is);
        
         int  w = mBitmap2.getWidth();
         int  h = mBitmap2.getHeight();
//  int x , y have to be smaller as w , h 
         int _color =  mBitmap2.getPixel(x, y);

242

Replace graphic accent diacritic Java Function | replace-graphic-accent-java-function


Replace diacritic marks: Á Č Ď É Ě Í Ň Ó Ř Š Ť Ú Ů Ý Ž
á č ď é ě í ň ó ř š ť ú ů ý ž


public String replaceDiacritic (String inputStr) {
	
	Map<String, String> replacements = new LinkedHashMap<String,String>() {{
		//Velká
		put("Á","A");
		put("Č","C");
		put("Ď","D");
		put("É","E");
		put("Ě","E");
		put("Í","I");
		put("Ň","N");
		put("Ó","O");
		put("Ř","R");
		put("Š","S");
		put("Ť","T");
		put("Ú","U");
		put("Ů","U");
		put("Ý","Y");
		put("Ž","Z");
		//Malá  "," ");
		put("á","a");
		put("č","c");
		put("ď","d");
		put("é","e");
		put("ě","e");
		put("í","i");
		put("ň","n");
		put("ó","o");
		put("ř","r");
		put("š","s");
		put("ť","t");
		put("ú","u");
		put("ů","u");
		put("ý","y");
		put("ž","z");
		}
	};
	for(Map.Entry<String, String> entry : replacements.entrySet()) {
          inputStr =  inputStr.replaceAll(entry.getKey(), entry.getValue());
         }	
	return inputStr;
}
	
257

Two boolean as one parameter value in function Java | two-boolean-as-one-parameter-value-in-function-java



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"); 




Editace: 2011-09-26 20:49:01
Počet článků v kategorii: 397
Url:how-set-gray-text-to-edittext-android-example

AD
11 Share
Share
Tweet