我有问题。我有两个活动: MainActivity 和 Pop ,我想从Main向Pop发送数字(double),我在这里有号码(IntCountValue)
btnClick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String countValue = txtCount.getText().toString();
double IntCountValue = Double.parseDouble(countValue);
IntCountValue +=1.5;
txtCount.setText(String.valueOf(IntCountValue));
}
});
我想在这里使用
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Pop.class);
intent.putExtra("Coins", IntCountValue);
startActivity(intent);
}
});
但它无法解决符号问题。有谁可以帮助我吗?
修改
Thx伙计们寻求帮助,我修好了,但我有另一个问题..
styles.xml
<style name="AppTheme.CustomTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
</style>
SecondActivity(弹出):
public class PopUp extends Activity {
TextView txtCount;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.popwindow);
txtCount = findViewById(R.id.textView12);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
getWindow().setLayout((int) (width*.8), (int) (height*.6));
Bundle extras = getIntent().getExtras();
if (extras == null) {
}
else
{
String bananas = extras.getString("Bananas");
txtCount.setText(bananas);
}
}
}
当我点击此框时,此框再次出现,但不是值(香蕉)显示单词TextView,我能以某种方式修复它吗?