我是android编程的新手,我很确定这就是我需要的东西.我有一个在启动时加载的页面,它有一个微调器,一些编辑文本框和两个按钮.一个按钮清除盒子并重置微调器.另一个按钮应该加载一个新的活动(我猜),我需要EditTexts中的内容和由它加载的微调器.
现在我让它做了一个祝酒词所以我可以测试一切都被正确抓住了.这是我现在的活动:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
public class directoryApp extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.searchscreen);
//Declaring these so I can use them when the button is clicked.
final Spinner depts = (Spinner) findViewById(R.id.dept);
final ArrayAdapter<CharSequence> deptsAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item);
deptsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
final EditText fname = (EditText) findViewById(R.id.fname);
final EditText lname = (EditText) findViewById(R.id.lname);
final EditText aim = (EditText) findViewById(R.id.aim);
final EditText phone = (EditText) findViewById(R.id.phone);
depts.setAdapter(deptsAdapter);
for(int i = 0 ; i < fillSpinner().length ; i++){
deptsAdapter.add(fillSpinner()[i]);
}
//Search Button on click, makes a "toast" message with grabbed web string and whatever was entered into the fields.
findViewById(R.id.search).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Here is where the search button does it's thing.
Toast.makeText(BNYDirectory.this, fname.getText() + " " + lname.getText() + " " + aim.getText() + " " + phone.getText() + " " + depts.getSelectedItem() + " " + deptIDs()[(int)depts.getSelectedItemId()], Toast.LENGTH_SHORT).show();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
我需要传递fname.getText(),lname.getText(),aim.getText(),phone.getText()和deptIDs()[(int)depts.getSelectedItemId()](我得到的所有这些都是字符串).
什么是进入下一页的最佳方式(我将使用这些来获得结果和显示)?也有可能在点击搜索时我可以让它从网上获取结果并将其放入字符串数组中并且只传递它,但我宁愿不这样做.
我可以用的任何例子?
| 归档时间: |
|
| 查看次数: |
2781 次 |
| 最近记录: |