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.

Font Family change on View dynamically Android Example


AD MOB

TypeFace, setTypeface, font, font family, array of String, Button create dynamically

@Override
protected void onStart() {
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
  48,
  55
);	
Typeface typeFace = Typeface.MONOSPACE;	
String [] ar = {"A","B","C","D","E","F","G","H","J","K"};
for (int i = 0; i < ar.length; i++) {
Button buttonView = new Button(this);
buttonView.setText(Html.fromHtml("<b>"+ar[i]+"</b>"));
buttonView.setTextColor(Color.BLUE);
buttonView.setTextSize(27.f);
buttonView.setTypeface(typeFace,Typeface.BOLD);
buttonView.setOnClickListener(mThisButtonListener);
if(i%2==0)
	mLayoutButtons.addView(buttonView, p);
else
	mLayoutButtonsNextRow.addView(buttonView, p);
	
_listOfButtons.add(buttonView);
}

	super.onStart();
}

//////// xml file
<TextView
    android:id="@+id/text01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20dp"
    android:fontFamily="Arial"
 />

397LW NO topic_id




AD

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


366

App have transparent menu Android | app-have-transparent-menu-android


If the app have transparent menu and you do not want this,
try delete @style/AppTheme in application tag in AndroidManifest.xml
and try run module - project. If menu is not transparent , maybe it caused

 <application
        android:allowBackup="true"
        android:icon="@drawable/dicts_ico"
        android:label="@string/app_name" 
        android:theme="@style/AppTheme" // delete this row - run app - try menu
 >


Or try set values\styles.xml into basic Theme

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Black">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>

274

Eclipse Error parsing the sdk Android | eclipse-error-parsing-the-sdk-android


[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Error parsing the sdk.
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Failed to create C:\Program Files\android\sdk\add-ons.
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Unable to parse SDK content.

You have to create add-ons folder as admin of PC
102

Unable to resolve id for attribute id Graphical layout editor Eclipse error | unable-to-resolve-id-for-attribute-id-graphical-layout-editor-eclipse-error


Problem: erroneous entry of id

<RadioButton android:id="idRadio"
                android:text="My radio button"/>


Solution: @+id/

<RadioButton android:id="@+id/idRadio"
                android:text="My radio button"/>
239

Admob ads not visible on emulator Android 4.1 | admob-ads-not-visible-on-emulator-android-4-1


If you using GoogleAdMobAdsSdk-4.0.4.jar in your project and set android:targetSdkVersion="17" in AndroidManifest.xml , ads will not visible on emulator with Android 4.0.3 or 4.1.
You have to set as android:targetSdkVersion="17"


<uses-sdk android:minSdkVersion="4" 
        android:targetSdkVersion="17" />


Update project.properties file - row with target to 17:

# Project target.
target=android-17
76

If, else if, else statement Java Android example | if-else-if-else-statement-java-android-example


if , else if, else statement with string as a switch statement in Java example source code.

MainClass.java

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = {"nothing", "Hello", "people"
				, "bye-bye", "hello", "world!", "end" };
		for (int i = 0; i < arrayOfString.length; i++) {
			
			if (arrayOfString[i].equals("Hello"))
				System.out.println(arrayOfString[i]);
			else if (arrayOfString[i].equals("people"))
				System.out.println(arrayOfString[i]);
			else if (arrayOfString[i].equals("hello"))
				System.out.println(arrayOfString[i]);
			else if (arrayOfString[i].equals("world!"))
				System.out.println(arrayOfString[i]);
			else // default
				System.out.println("Default");
		}
	}
}
/*
Default
Hello
people
Default
hello
world!
Default 
 */


Editace: 2013-03-03 21:21:12
Počet článků v kategorii: 397
Url:font-family-change-on-view-android-example

AD
11 Share
Share
Tweet