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.

Whittled superscript sup tag TextView Android issue


AD MOB

Issue: Cropped superscript index between tags sup /sup is not correctly visible in TextView or View as Button.

String s = "10<sup>12 </sup>";
textView.setText(Html.fromHtml(s)); // 12 will cropped 
// solution:
s = "10<sup>12 </sup>\t	"; // add behind ending of sup tag the tabulator \t, 
// but not char \t but only press to TAB key!!! in source code
textView.setText(Html.fromHtml(s)); // 12 is visible correctly


textview-superscript-issue

397LW NO topic_id




AD

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


104

Unable to find explicit activity class Android Eclipse error | unable-to-find-explicit-activity-class-android-eclipse-error


android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.my_package/com.example.my_package.MainClass}; have you declared this activity in your AndroidManifest.xml?

Is MainClass.java in AndroidManifest as a activity ?
AndroidManifest.xml example

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="//schemas.android.com/apk/res/android"
      package="com.example.my_packag"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MainClass"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>
20

How set gray text to EditText Android example | how-set-gray-text-to-edittext-android-example


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



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 
 */
29

ListView add item click item basic Android example code | listview-add-item-click-item-basic-android-example-code


Definition of ListView in layout main.xml file Android example



<ListView android:id="@+id/idListView"
        android:background="#7700CC00"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent" /> 



Code in Main.java ListView example source code Java Android

public class Main extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ListView mlistView = (ListView) findViewById(R.id.idListView);
        mlistView.setAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, 
                new String[] {"Game", "Help", "Home site"}));
    
        mlistView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
              // When clicked, show a toast with the TextView text Game, Help, Home
              Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
                  Toast.LENGTH_SHORT).show();
            }
          });
     }
}


333

SimpleCursorAdapter deprecated | simplecursoradapter-deprecated


Constructor SimpleCursorAdapter is deprecated.
If using api 11 and above, you can try add last parameter 0.


Cursor cursor = managedQuery(...........,,,,);
// Specify the columns we want to display in the result
            String[] from = new String[] { KEY_WORD,
                                           KEY_DEFINITION };

            // Specify the corresponding layout elements where we want the columns to go
            int[] to = new int[] { R.id.word,
                                   R.id.definition };
// deprecated 
 SimpleCursorAdapter words =
            new SimpleCursorAdapter(this,
                    R.layout.result, cursor, from, to);
// working
 SimpleCursorAdapter words =
            new SimpleCursorAdapter(this,
                    R.layout.result, cursor, from, to, 0); // to, 0!!!!


//working in Fragment
SimpleCursorAdapter  mAdapter = new SimpleCursorAdapter(getActivity(),
                android.R.layout.simple_list_item_2, null,
                new String[] { "name", "age" }, // cursor parameters
                new int[] { android.R.id.text1, android.R.id.text2 }, 0);




Editace: 2013-12-09 10:10:04
Počet článků v kategorii: 397
Url:whittled-superscript-sup-tag-textview-android-issue

AD
11 Share
Share
Tweet