Answer the question
In order to leave comments, you need to log in
Java.Get int from EditText or are there other ways?
The essence is this, they gave the task, it is necessary that by pressing a button in the application, I receive data from the html page, I did it! BUT it is necessary that a person can enter a number (id), press the button, and get the text corresponding to this id. Here is the
package code com.example.android.fivecardview;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
public class MainActivity extends AppCompatActivity {
Button button;
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
final int a = 3;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
textView = (TextView) findViewById(R.id.text1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Ion.with(getApplicationContext())
.load("https://jsonplaceholder.typicode.com/posts/" + a)
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String result) {
textView.setText(result);
}
});
}
});
}
}
Answer the question
In order to leave comments, you need to log in
Well and to look why to be painted? Yes, and in Google there is a lot of information on translating a string into a number.
And why actually use the int value if everything is passed to a string? Isn't it easier to create a string variable and pass it?
editText.getText().toString() to help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question