Back to project page Ascent.
The source code is released under:
GNU General Public License
If you think the Android project Ascent listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package be.sourcery.ascent; //from w w w . java2 s . c om /* * This file is part of Ascent. * * Ascent is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Ascent is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Ascent. If not, see <http://www.gnu.org/licenses/>. */ import android.content.Intent; import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; public class AddCragActivity extends MyActivity { InternalDB db = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.add_crag); setTitle(R.string.addCrag); setupActionBar(); EditText cragView = (EditText)findViewById(R.id.crag); cragView.requestFocus(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); db = new InternalDB(this); // Capture our button from layout Button button = (Button)findViewById(R.id.ok); // Register the onClick listener with the implementation above button.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText cragView = (EditText)findViewById(R.id.crag); String name = cragView.getText().toString(); EditText countryView = (EditText)findViewById(R.id.country); String country = countryView.getText().toString(); db.addCrag(name, country); setResult(RESULT_OK); finish(); } }); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // app icon in action bar clicked; go home Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } } }