我想编写一个小的java程序,询问用户输入并检查输入是否在数组中,如果输入在数组中,则将用户重定向到HTML页面。
class Thing < ActiveRecord::Base
...
def save_with_lock
self.user.with_lock do
self.save
end
end
end
class ThingsController < ApplicationController
...
def create
@thing = current_user.things.new #current_user is a User
if @thing.save_with_lock
redirect_to @thing
else
render 'new'
end
end
end
答案 0 :(得分:1)
使用此
package ed.letslearn.com.apptwo;
import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText thesentvalue=(EditText)findViewById(R.id.editText2);
Button b=(Button)findViewById(R.id.button);
Bundle bundle=getIntent().getExtras();
String text=bundle.getString("test");
thesentvalue.setText(text);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent goBack = new Intent("ed.letslearn.com.appone");
goBack.putExtra("result", "Sent from App two");
setResult(Activity.RESULT_OK, goBack);
finish();
}
});
}
}