Note that there are some explanatory texts on larger screens.

plurals
  1. POtextView wont display decimals
    primarykey
    data
    text
    <p>I am having an issue with my program, my textveiw will not display any decimals, heres the break down on whats happeneing. The user enters a number in a textEdit (Also how do i make the textedit only accept numbers AND a decimal point?) that number gets converted to a int, sent to my second activity, diveded by 3600, then displayed in a textveiw box. The issue is that when that number is displayed it has no decimal value, for example if its less than 1 it will not display anything, how can i go about fixing this? i need it to at least go to the 1000th place. Here is my code one activity1:</p> <pre><code> public void sendMessage(View view) { // Do something in response to button Intent intent = new Intent(this, PayTracker.class); // Gather text from text boxes EditText editText = (EditText) findViewById(R.id.hourly_wage); //Create String from text String message1 = editText.getText().toString(); //Convert String to Int int HW = 0; try{ HW = Integer.valueOf(message1); } catch(NumberFormatException nfe){ //do something else here //for e.g. initializing default values to your int variables } // Send Integers to PayTracker.java intent.putExtra(MESSAGE_HW, HW); // start new activity startActivity(intent); </code></pre> <p>And then this is activity2 where the number needs to be displayed:</p> <pre><code> public void sendMessage(View view) { // Receive messages from options page Intent intent = getIntent(); int HW = intent.getIntExtra(Options.MESSAGE_HW, 0); // Calculate pay per second int PPS = 0; PPS = (HW/3600); // set textView TextView textView = (TextView) this.findViewById(R.id.yourpay); textView.setText(String.valueOf(PPS)); } </code></pre> <p>Any help would be appreciated! thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload