80,330
社区成员
发帖
与我相关
我的任务
分享
public class MainActivity extends Activity implements OnClickListener {
private Button button1=null;
private EditText edit1=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1=(Button)findViewById(R.id.bt);
button1.setOnClickListener(this);
edit1=(EditText)findViewById(R.id.et);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt:
String str1=edit1.getText().toString().trim();
Intent intent=new Intent();
intent.putExtra("str",str1);
intent.setClass(MainActivity.this,NextActivity.class);
startActivity(intent);
break;
default:break;
}
}}
public class NextActivity extends Activity {
private TextView text1=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_next);
text1=(TextView)findViewById(R.id.tv);
Intent inte=getIntent();
String data=inte.getStringExtra("str");
text1.setText("¥"+data);
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.pay.MainActivity"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_launcher"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="向个人用户'***(**)'转账" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="转账金额" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥"
android:textSize="37sp" />
<EditText
android:id="@+id/et"
android:inputType="numberDecimal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="添加留言" />
</LinearLayout>
<Button
android:id="@+id/bt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00ff00"
android:text="转账" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<RelativeLayout
android:id="@+id/rl1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp" >
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_launcher"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:paddingBottom="8dp"
android:text="支付成功"
android:textColor="#00ff00" />
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/tv2"
android:textSize="30sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl2"
android:layout_below="@+id/rl1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="40dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="收款人" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_launcher"
android:layout_alignParentRight="true"
android:text="***(**)" />
</RelativeLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
public static String getTwo(int s){
Double d = 0.00;
try {
d = Double.valueOf(s);
}catch (Exception e){
LogUtils.i("格式化","字符串非数字格式");
}
return String.format("%.2f",d);
}