Android Java多于1个返回语句

时间:2015-07-21 21:01:42

标签: java android methods return

我在方法中得到了这个

    View android = inflater.inflate(R.layout.asd_frag, container, false);
    ((TextView) android.findViewById(R.id.textViewAsd01)).setText("asd");
    return android;
    View android02 = inflater.inflate(R.layout.asd02_frag, container, false);
    ((TextView) android.findViewById(R.id.textViewAsd02)).setText("asd02");
    return android02;

所以问题是你不能在一个方法中返回2个return语句,有人知道一个技巧来实现这个。

1 个答案:

答案 0 :(得分:0)

创建一个包含2个值的自定义对象,或使用public class Backgroundtask extends AsyncTask<String, Void, String> { AlertDialog alertDialog; AlertDialog alertDialog2; Context ctx; Userlocalstore userlocalstore; String res_name , res_username , res_dob , res_email , res_id , res_pass; Backgroundtask(Context ctx) { this.ctx =ctx; } @Override protected void onPreExecute() { alertDialog = new AlertDialog.Builder(ctx).create(); alertDialog.setTitle("Login Information...."); alertDialog2 = new AlertDialog.Builder(ctx).create(); alertDialog2.setTitle("Apologies"); } @Override protected String doInBackground(String... params) { String reg_url = "http://8miles.freeiz.com/Register.php"; String login_url = "http://8miles.freeiz.com/getuserinfo.php"; String method = params[0]; if (method.equals("Register")) { String name = params[1]; String user_name = params[2]; String user_pass = params[3]; String email = params[4]; String dob = params[5];

相关问题