settext

Android: Can't update textview in Fragment from Activity. NullPointerException

微笑、不失礼 提交于 2019-12-13 08:28:11
问题 I'm trying to update textview in fragment from another activity. But I'm getting a NUllPointerException when calling the setText method. I have tried the following, but still getting the NPE. 1. Tried accessing the fragments textview with FindViewbyId in activity. 2. Tried using a method in fragment and calling it from activity and passing the value as parameters FragHome Activity public class FragHome extends AppCompatActivity implements TabLayout.OnTabSelectedListener { Handler bluetoothIn;

cannot trigger the textchanged event while using sendmessage and WM_SETTEXT but PostMessage can

删除回忆录丶 提交于 2019-12-13 06:28:55
问题 I have a problem similar to this but I still cannot solve it. I am trying to edit a textbox for contrast and another for brightness inside an image viewer program from my wpf program. Changing the values inside these two textbox will trigger the change of the image right away. Using Spy++ allows me to get the exact window handle for both of those textbox and I've tried these following methods but still can't get what I need from my C# program. Method 1: This method allows me to change the

Live updating one JtextArea from another JtextArea

柔情痞子 提交于 2019-12-13 05:07:55
问题 I am attempting to write a program that will display two Jtextareas, both of which are editible. The goal is to when you edit textAreaRom (entering a roman numeral) the second area (textAreaArab) will display the Arabic Number equivalent. But the thing is I can not get this to happen in real-time. I have read about using DocumentListeners but, this is one of the first times I have ever done GUI programming and I am not to sure on how I would implement it. Anything helps. I am new to GUI stuff

How to rename set of JButtons?

我的梦境 提交于 2019-12-13 03:58:36
问题 I have 25 jButtons and i want to change their texts from a loop. Here is my code for 1 button.. void changeText(){ jButton1.setText(jButton1.getText().toUpperCase()); } I want to do the same for all other buttons without writing a method for each. Is it possible to use something like this? void changeText(){ for(int i=0;i<25;i++){ String x = "jButton"+i; x.setText(x.getText().toUpperCase()); } } Surely this wont work. Please suggest me a method. 回答1: You can do this by adding the buttons to a

Java Swing load file into JEditorPane

杀马特。学长 韩版系。学妹 提交于 2019-12-13 03:49:24
问题 I'm trying to write text-editor type application in Java/Swing. I have the FileChooser working and I can print out the contents of the file to the console. I want to load the file into a JEditorPane When I call setText(), it updates the value of the text (I can print the result of getText, but the actual EditorPane is not refreshing). I've tried calling repaint/revalidate on the JEditorPane, the encapsulating JScrollPane but nothing will refresh the text to what I sent to setText. Am I

Setting custom format for numbers in TextView [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-12-13 01:27:37
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I format a number in java? String.format() to format double in java I want to be able to take the output from a double variable (called double) and put it in a TextView along with some String text (called outputPref, which just contains "cubic mm") like below displayAnswer.setText(volume + " " + outputPref); This works fine, however, the number shows in the TextView as the full double (with many, many

setText on a TextView will overwrite previous text

扶醉桌前 提交于 2019-12-12 15:03:10
问题 I have a text view that is by itself as part of a linear layout. The XML is: <TextView android:id="@+id/label_text" android:layout_width="fill_parent" android:layout_height="77dp" android:layout_marginTop="3dp"/> In the main program I first set the text view to a value: private TextView character_speaking; protected void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); character_speaking = (TextView) findViewById(R.id.label

My setText isn't updating my JTextField?

对着背影说爱祢 提交于 2019-12-12 06:46:26
问题 So I'm missing something here, but I can't get my setAttributes method to update the agility text field like it's supposed to. The class that calls the method and the call works fine passing in the needed values as seen by the system.out.println(agility). However in just the line below I try to set the agilityAmount txtfield and it doesn't display. What am I doing wrong? class GraphicalInterface extends JFrame implements Runnable, KeyListener { GraphicalInterface() { } JFrame mainwindow; /

cannot touch view from another thread, how to make it possible?

回眸只為那壹抹淺笑 提交于 2019-12-12 03:19:16
问题 I cant figure out why i cant set text to my textView tv. getting: E/AndroidRuntime(686): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. I tried many ways to make it right. As you can see i tried Handler because i had the same problem with toasts. Now toast works but setText doesnt :(( Please someone help me, how should i configure this handler? public class calculate extends Activity implements OnClickListener

setText doesn't set text

笑着哭i 提交于 2019-12-12 03:18:58
问题 I have a class that fetches som data from a website. I've followed TheNewBoston's tutorial (147-149 I think) and copied what he writes exactly , but it doesn't work for me. The problem is the setText . I try to switch tv.setText(returned) to tv.setText("Hello") but it doesn't change. Anyone know what's wrong? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv= (TextView) findViewById(R.id.text1);