textview

how to add font in Android Application

可紊 提交于 2020-01-13 02:43:19
问题 i am making one application in Android 2.2 in that application i want to show hindi text in TextView in Android application. (how to add "मैं छात्र हूँ" word in Text view) Please help me.. 回答1: Add your font to assets folder in your project and use the below snippet TextView hindiTextView=(TextView)findViewById(R.id.txtbx); Typeface hindiFont=Typeface.createFromAsset(getAssets(),"fonts/fontname.ttf"); mytextView.setTypeface(hindiFont); Hope its helpful. 回答2: 1) add "fonts" folder inside of

Find exact coordinates of a single Character inside a TextView

独自空忆成欢 提交于 2020-01-12 14:23:29
问题 Currently I'm using paintObject.measureText(textCopy.substring(0,i)) while iterating through a copy of the TextView's text. For example, measureText("abc".substring(0,1)) will give me the relative x coordinates of 'b'. The y coordinate I get from layout.getLineTop() . This is working but not accurate for x coordinates for non-monospaced fonts. I can calibrate a little, but on each device it works differently. The best solution I can think of is to overwrite the class that is responsible for

Hide TextView after some time in Android

こ雲淡風輕ζ 提交于 2020-01-12 14:11:17
问题 I want to hide TextView after some time interval say 3 seconds. I googled and found some code and I tried code as shown below but It is not working. Please tell me what is the wrong with this ? tvRQPoint.setText("+0"); tvRQPoint.postDelayed(new Runnable() { public void run() { tvRQPoint.setText("+0"); } }, 3000); One more thing, how to remove timeout ? As I am using this on click event of ListView , If user clicks on one option and then clicks on second option, then as 3 seconds got over

Implement onClick only for a TextView compound drawable

别来无恙 提交于 2020-01-12 04:01:10
问题 I need to have some text with a drawable on the left and I want to execute some code when the user clicks/touches the image (only the image, not the text), so I used a LinearLayout with a TextView and an ImageView which is clickable and launches an onClick event. The XML parser suggests me to replace this with a TextView with a compound drawable , which would draw the same thing with far less lines of XML .. My question is "can I specify I want to handle an onClick event only on the drawable

chemistry formula on Android

孤街浪徒 提交于 2020-01-11 19:59:21
问题 I'm developing an android project and I want to render some chemistry formula. I wrote the following code and I got the following result. I create a custom string and show it in a textview. But my question is this: Is this the best way to do this? And is there another way to handle that? str = new SpannableString(Html.fromHtml("2H<sup>+</sup> + So<sub size = 2>4</sub><sup size = 2>2-</sup> --> H<sub size =2>2</sub>So<sub size = 2>4</sub>")); ss1.setSpan(new RelativeSizeSpan(0.6f), 2,3, 0); //

Error with Updating Text View from java file

不羁的心 提交于 2020-01-11 14:41:28
问题 Sorry this may be a simple error, new to android dev, but I've been searching the web looking for answers and none of them solutions seem to work. Every time I try run the code below it fails, any ideas why/how to fix it. First is the java file public class Services extends Activity { Report2 r; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle data = getIntent().getExtras(); r = data.getParcelable("RemarksReport"); setContentView(R

How to update a TextView from within onPostExecute

ⅰ亾dé卋堺 提交于 2020-01-11 14:38:07
问题 Need help here, about onPostExecute. If I want to put the update on textView what should be the code and what should I do?. @Override protected Value[] doInBackground(Integer... params) { ApiClient apiClient = new ApiClient(API_KEY); Variable batteryLevel = apiClient.getVariable(VARIABLE_ID); Value[] variableValues = batteryLevel.getValues(); return variableValues; } @Override protected void onPostExecute(Value[] variableValues) { // Update your views here } 回答1: Do as follows, save reference

How to check if a TextView String has been trimmed (marquee)?

早过忘川 提交于 2020-01-11 03:28:10
问题 If a TextView does not have enough space in its parent element, I will show an icon. A tab on that text or the icon will be used to call an alert dialog with the full string. So i need to know if a TextView has been trinmmed. 回答1: Claculate the width of TextView and also calculate the width of text which wil be displayed in the textview. If the width of text is more that the width of textView that means your have to call dialog because because the text will be marqued. Otherwise the text

Views in Fragment are null

非 Y 不嫁゛ 提交于 2020-01-09 12:08:31
问题 Im still working on my Android App. Now im facing this problem: Code: package smoca.ch.kreagen.Fragments; import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import io.realm.Realm; import io.realm.RealmQuery; import smoca.ch.kreagen.R; import smoca.ch.kreagen.models.Idea; public

Views in Fragment are null

谁说我不能喝 提交于 2020-01-09 12:06:11
问题 Im still working on my Android App. Now im facing this problem: Code: package smoca.ch.kreagen.Fragments; import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import io.realm.Realm; import io.realm.RealmQuery; import smoca.ch.kreagen.R; import smoca.ch.kreagen.models.Idea; public