Search Results

Search found 334 results on 14 pages for 'edittext'.

Page 5/14 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • IME window overlap cursor in Edittext, how to prevent it?

    - by backspace7
    I'm using Edittext and it has images and texts. Then, I add image file on Edittext and I click Edittext, IME window shows, naturally. ( * At that time cursor is located at right-bottom corner of added image file.) The problem is IME window overlap cursor, so users complain that 'where is my cursor?' How to prevent that IME window overlap cursor?

    Read the article

  • How to get data from dynamically created EditText views and insert it into an array?

    - by Snwspeckle
    So basically what I need my program to do at this point is that when I click the submit button, I need to loop through each dynamic row of the ListView and grab the value in the EditText view and then insert that into an array which I will do further calculations after. Here is my code right now. package com.hello_world; import java.util.ArrayList; import com.hello_world.ByteInputActivity.MyAdapter.ViewHolder; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnFocusChangeListener; import android.view.View.OnKeyListener; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; public class ByteInputActivity extends Activity { private ListView myList; private MyAdapter myAdapter; private Integer resQuestions; private Integer indexVal = 0; private View caption; ViewHolder holder; ArrayList<Integer> intArrayList = new ArrayList<Integer>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fieldlist); //Gets number of questions from MainActivity Bundle extras = getIntent().getExtras(); if(extras !=null) { resQuestions = extras.getInt("index"); } myList = (ListView) findViewById(R.id.FieldList); myList.setItemsCanFocus(true); myAdapter = new MyAdapter(); myList.setAdapter(myAdapter); Button submit = (Button) findViewById(R.id.btn_New); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < myList.getCount() ; i++) { View vListSortOrder; vListSortOrder = myList.getChildAt(i); String temp = holder.caption.getText().toString(); Log.e("VALUES", "" +temp); } } }); } public class MyAdapter extends BaseAdapter { private LayoutInflater mInflater; public ArrayList myItems = new ArrayList(); public MyAdapter() { mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < resQuestions; i++) { ListItem listItem = new ListItem(); listItem.caption = "Index " + i; listItem.indexText = "Index " + i; myItems.add(listItem); indexVal += 1; } notifyDataSetChanged(); } public int getCount() { return myItems.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.item, null); holder.indexText = (TextView) convertView .findViewById(R.id.textView1); holder.caption = (EditText) convertView .findViewById(R.id.ItemCaption); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } //Fill EditText with the value you have in data source holder.caption.setText(""); holder.caption.setId(position); holder.indexText.setText("Index " + position); holder.indexText.setId(position); //we need to update adapter once we finish with editing holder.caption.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus){ final int position = v.getId(); final EditText Caption = (EditText) v; myItems.set(position, Caption.getText().toString()); } } }); return convertView; } class ViewHolder { EditText caption; TextView indexText; } class ListItem { String caption; String indexText; } } }

    Read the article

  • Getting a Soft Keyboard for a EditTextPreference

    - by user313135
    Hello, I have a shared preference that is being accesed via an EditTextPreference. I am in the process of porting this application to a device that does not have a hardware keyboard for text entry. When the time comes to modify the EditTextPreference, there is no soft keyboard that becomes available, and I am at a loss as to how to invoke the soft keyboard for text input to edit this preference. Thanks

    Read the article

  • Upload .txt and keep formating

    - by s2xi
    I have been trying to upload a .txt to my server via a simple php script I made. Everything seems to uploaded correctly, if I open the .txt in Dreamweaver I can see all the formatting is still in tact with spaces and paragraph breaks. The problem I have is when I try to open that file with PHP and import the contents onto my site. I'm not using an editor right now, just a simple div where the contents are echoed. I don't have much experience with uploading/downloading using PHP. Am I not using a command to handle the file contents and keep the initial formatting? In the end I want the user to upload a file, and have PHP read the file and extract certain elements from it based on the number of spaces between paragraph breaks and such. I was able to actually echo the .txt using URLENCODE() which kept the formatting and made all my spaces +'s. Thats the closes I got, but the original file isn't uploaded in the format so I can't do a count for +'s and select x characters after the last +. Hmmm, if someone knows of a script already available that can do this or similar to with me just tweaking that would be awesome.

    Read the article

  • setText() without calling onTextChanged()

    - by user1537779
    Is there a way I can set text to an EditTextView, but not trigger its onTextChanged() or afterTextChanged(). In onTextChanged(), I am making a server call to get autocompletes. But once the user selects from the dropdown, I want to set text to the EditTextView, but it again calls the server and shows the dropdown. While I can have a flag not to make server call when selected from dropdown, using the onItemClick() on dropdown(ListView). How can I remove the flag again, if the user tried to edit the text later.

    Read the article

  • Android: how to hide and then show View with animation effect?

    - by tomash
    I have similar question like this one: http://stackoverflow.com/questions/2079074/update-layout-with-the-animation Basically: I have one vertical LinearLayout View with edittext, button and then list. I'd like to hide exittext after pressing button to make more space for list (button will go up). On second press edittext should be visible again. Edittext and button have "wrap_content" height. I'd like to hide and show edittext with animation. I succeeded to animate hiding by overloading Animation's applyTransformation: final float edittextheight= edittext.getHeight(); [....] @Override protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); android.view.ViewGroup.LayoutParams lp = edittext.getLayoutParams(); lp.height = (int)(edittextheight*(1.0-interpolatedTime)); edittext.setLayoutParams(lp); } Problem: I don't know how to calculate height to animate showing - edittext.getHeight(); returns 0 when widget is hidden and in layout definition I'm using "wrap_content". Help?

    Read the article

  • I get java.lang.NullPointerException when trying to get the contents of the database in Android

    - by ncountr
    I am using 8 EditText boxes from the NewCard.xml from which i am taking the values and when the save button is pressed i am storing the values into a database, in the same process of saving i am trying to get the values and present them into 8 different TextView boxes on the main.xml file and when i press the button i get an FC from the emulator and the resulting error is java.lang.NullPointerException. If Some 1 could help me that would be great, since i have never used databases and this is my first application for android and this is the only thing keepeng me to complete the whole thing and publish it on the market like a free app. Here's the full code from NewCard.java. public class NewCard extends Activity { private static String[] FROM = { _ID, FIRST_NAME, LAST_NAME, POSITION, POSTAL_ADDRESS, PHONE_NUMBER, FAX_NUMBER, MAIL_ADDRESS, WEB_ADDRESS}; private static String ORDER_BY = FIRST_NAME; private CardsData cards; EditText First_Name; EditText Last_Name; EditText Position; EditText Postal_Address; EditText Phone_Number; EditText Fax_Number; EditText Mail_Address; EditText Web_Address; Button New_Cancel; Button New_Save; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.newcard); cards = new CardsData(this); //Define the Cancel Button in NewCard Activity New_Cancel = (Button) this.findViewById(R.id.new_cancel_button); //Define the Cancel Button Activity/s New_Cancel.setOnClickListener ( new OnClickListener() { public void onClick(View arg0) { NewCancelDialog(); } } );//End of the Cancel Button Activity/s //Define the Save Button in NewCard Activity New_Save = (Button) this.findViewById(R.id.new_save_button); //Define the EditText Fields to Get Their Values Into the Database First_Name = (EditText) this.findViewById(R.id.new_first_name); Last_Name = (EditText) this.findViewById(R.id.new_last_name); Position = (EditText) this.findViewById(R.id.new_position); Postal_Address = (EditText) this.findViewById(R.id.new_postal_address); Phone_Number = (EditText) this.findViewById(R.id.new_phone_number); Fax_Number = (EditText) this.findViewById(R.id.new_fax_number); Mail_Address = (EditText) this.findViewById(R.id.new_mail_address); Web_Address = (EditText) this.findViewById(R.id.new_web_address); //Define the Save Button Activity/s New_Save.setOnClickListener ( new OnClickListener() { public void onClick(View arg0) { //Add Code For Saving The Attributes Into The Database try { addCard(First_Name.getText().toString(), Last_Name.getText().toString(), Position.getText().toString(), Postal_Address.getText().toString(), Integer.parseInt(Phone_Number.getText().toString()), Integer.parseInt(Fax_Number.getText().toString()), Mail_Address.getText().toString(), Web_Address.getText().toString()); Cursor cursor = getCard(); showCard(cursor); } finally { cards.close(); NewCard.this.finish(); } } } );//End of the Save Button Activity/s } //======================================================================================// //DATABASE FUNCTIONS private void addCard(String firstname, String lastname, String position, String postaladdress, int phonenumber, int faxnumber, String mailaddress, String webaddress) { // Insert a new record into the Events data source. // You would do something similar for delete and update. SQLiteDatabase db = cards.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(FIRST_NAME, firstname); values.put(LAST_NAME, lastname); values.put(POSITION, position); values.put(POSTAL_ADDRESS, postaladdress); values.put(PHONE_NUMBER, phonenumber); values.put(FAX_NUMBER, phonenumber); values.put(MAIL_ADDRESS, mailaddress); values.put(WEB_ADDRESS, webaddress); db.insertOrThrow(TABLE_NAME, null, values); } private Cursor getCard() { // Perform a managed query. The Activity will handle closing // and re-querying the cursor when needed. SQLiteDatabase db = cards.getReadableDatabase(); Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null, null, ORDER_BY); startManagingCursor(cursor); return cursor; } private void showCard(Cursor cursor) { // Stuff them all into a big string long id = 0; String firstname = null; String lastname = null; String position = null; String postaladdress = null; long phonenumber = 0; long faxnumber = 0; String mailaddress = null; String webaddress = null; while (cursor.moveToNext()) { // Could use getColumnIndexOrThrow() to get indexes id = cursor.getLong(0); firstname = cursor.getString(1); lastname = cursor.getString(2); position = cursor.getString(3); postaladdress = cursor.getString(4); phonenumber = cursor.getLong(5); faxnumber = cursor.getLong(6); mailaddress = cursor.getString(7); webaddress = cursor.getString(8); } // Display on the screen add for each textView TextView ids = (TextView) findViewById(R.id.id); TextView fn = (TextView) findViewById(R.id.firstname); TextView ln = (TextView) findViewById(R.id.lastname); TextView pos = (TextView) findViewById(R.id.position); TextView pa = (TextView) findViewById(R.id.postaladdress); TextView pn = (TextView) findViewById(R.id.phonenumber); TextView fxn = (TextView) findViewById(R.id.faxnumber); TextView ma = (TextView) findViewById(R.id.mailaddress); TextView wa = (TextView) findViewById(R.id.webaddress); ids.setText(String.valueOf(id)); fn.setText(String.valueOf(firstname)); ln.setText(String.valueOf(lastname)); pos.setText(String.valueOf(position)); pa.setText(String.valueOf(postaladdress)); pn.setText(String.valueOf(phonenumber)); fxn.setText(String.valueOf(faxnumber)); ma.setText(String.valueOf(mailaddress)); wa.setText(String.valueOf(webaddress)); } //======================================================================================// //Define the Dialog that alerts you when you press the Cancel button private void NewCancelDialog() { new AlertDialog.Builder(this) .setMessage("Are you sure you want to cancel?") .setTitle("Cancel") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { NewCard.this.finish(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .show(); }//End of the Cancel Dialog }

    Read the article

  • EditText and Button on the same line with Textiew underneath?

    - by Kevin
    Hi, I am trying to have an EditText widget next to a button with a text view underneath. The EditText should resize and fill the screen accordingly, while the button's width is always only what it needs to be by setting the width to wrap_content. The layout should not be relative. Below is the code I have so far some of which was found here on StackOverflow. Removing the text view gives the desired appearance for the EditText and button, but when the TextView is added the view goes to ... well. Not sure why the code is not showing? I put it into a < code< pre block without success. http://pastebin.com/WgH6qrTm

    Read the article

  • Implement date picker and time picker in button click and store in edit text boxes

    - by user3597791
    Hi I am trying to implement a date picker and time picker in button click and store in edit text boxes. I have tried numerous things but since i suck at coding I cant get any of them to work. Please find my class and xml below and i would be grateful for any help import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; public class NewEvent extends Activity { private static int RESULT_LOAD_IMAGE = 1; private EventHandler handler; private String picturePath = ""; private String name; private String place; private String date; private String time; private String photograph; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.new_event); handler = new EventHandler(getApplicationContext()); ImageView iv_user_photo = (ImageView) findViewById(R.id.iv_user_photo); iv_user_photo.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, RESULT_LOAD_IMAGE); } }); Button btn_add = (Button) findViewById(R.id.btn_add); btn_add.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { EditText et_name = (EditText) findViewById(R.id.et_name); name = et_name.getText().toString(); EditText et_place = (EditText) findViewById(R.id.et_place); place = et_place.getText().toString(); EditText et_date = (EditText) findViewById(R.id.et_date); date = et_date.getText().toString(); EditText et_time = (EditText) findViewById(R.id.et_time); time = et_time.getText().toString(); ImageView iv_photograph = (ImageView) findViewById(R.id.iv_user_photo); photograph = picturePath; Event event = new Event(); event.setName(name); event.setPlace(place); event.setDate(date); event.setTime(time); event.setPhotograph(photograph); Boolean added = handler.addEventDetails(event); if(added){ Intent intent = new Intent(NewEvent.this, MainEvent.class); startActivity(intent); }else{ Toast.makeText(getApplicationContext(), "Event data not added. Please try again", Toast.LENGTH_LONG).show(); } } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { Uri imageUri = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(imageUri, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); picturePath = cursor.getString(columnIndex); cursor.close(); Here is my xml: <?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:orientation="vertical" android:padding="10dp"> <TextView android:id="@+id/tv_new_event_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add New Event" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_alignParentTop="true" /> <Button android:id="@+id/btn_add" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Add Event" android:layout_alignParentBottom="true" /> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/tv_new_event_title" android:layout_above="@id/btn_add"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:id="@+id/iv_user_photo" android:src="@drawable/add_user_icon" android:layout_width="100dp" android:layout_height="100dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Event:" /> <EditText android:id="@+id/et_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Place:" /> <EditText android:id="@+id/et_place" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Date:" /> <EditText android:id="@+id/et_date" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="date" /> <Button android:id="@+id/button" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <requestFocus /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Time:" /> <EditText android:id="@+id/et_time" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="time" /> <Button android:id="@+id/button1" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" /> <requestFocus /> </LinearLayout> </ScrollView> </RelativeLayout>

    Read the article

  • why my code still cannot connect with database? [closed]

    - by Wen Teng
    package com.mems.travis; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONObject; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; public class UserRegister extends Activity { JSONParser jsonParser = new JSONParser(); EditText inputName; EditText inputUsername; EditText inputEmail; EditText inputPassword; RadioButton button1; RadioButton button2; Button button3; int success = 0; // url to create new product private static String url_register_user = "http://192.168.1.100/MEMS/add_user.php"; // JSON Node names private static final String TAG_SUCCESS = "success"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_register); // Edit Text inputName = (EditText) findViewById(R.id.nameTextBox); inputUsername = (EditText) findViewById(R.id.usernameTextBox); inputEmail = (EditText) findViewById(R.id.emailTextBox); inputPassword = (EditText) findViewById(R.id.pwTextBox); // Create button //RadioButton button1 = (RadioButton) findViewById(R.id.studButton); // RadioButton button2 = (RadioButton) findViewById(R.id.shopownerButton); Button button3 = (Button) findViewById(R.id.regSubmitButton); // button click event button3.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String name = inputName.getText().toString(); String username = inputUsername.getText().toString(); String email = inputEmail.getText().toString(); String password = inputPassword.getText().toString(); if (name.contentEquals("")||username.contentEquals("")||email.contentEquals("")||password.contentEquals("")) { AlertDialog.Builder builder = new AlertDialog.Builder(UserRegister.this); // 2. Chain together various setter methods to set the dialog characteristics builder.setMessage(R.string.nullAlert) .setTitle(R.string.alertTitle); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked OK button } }); // 3. Get the AlertDialog from create() AlertDialog dialog = builder.show(); } else { new RegisterNewUser().execute(); } } }); } class RegisterNewUser extends AsyncTask<String, String, String>{ protected String doInBackground(String... args) { String name = inputName.getText().toString(); String username = inputUsername.getText().toString(); String email = inputEmail.getText().toString(); String password = inputPassword.getText().toString(); // Building Parameters List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("name", name)); params.add(new BasicNameValuePair("username", username)); params.add(new BasicNameValuePair("email", email)); params.add(new BasicNameValuePair("password", password)); // getting JSON Object // Note that create product url accepts POST method JSONObject json = jsonParser.makeHttpRequest(url_register_user, "GET", params); // check log cat for response Log.d("Send Notification", json.toString()); try { int success = json.getInt(TAG_SUCCESS); if (success == 1) { // successfully created product Intent i = new Intent(getApplicationContext(), StudentLogin.class); startActivity(i); finish(); } else { // failed to register } } catch (Exception e) { e.printStackTrace(); } return null; } } }

    Read the article

  • How can I use text from an EditText Field into a web page?

    - by S.M. Hasibur Rahman
    Hi there, I am creating a library search engine based on android. I want to have an EditText field in my application, where user will put the search text. And upon clicking the search button it should search using the library web page. I want to use the text being put in the EditText field to be used by the web page in the background and want to show the result to the user. Could find a clue. I will be really grateful if you could answer asap. Thanks. / Hasibur Rahman

    Read the article

  • how to make the android app load faster?

    - by Tapan Desai
    I have designed an application for android, in which i am showing a splash screen before the main activity is started but the application takes 5-7 seconds to start on low-end devices. I want to reduce that time to as low as possible. I have been trying to reduce the things to be done in onCreate() but now i cannot remove any thing more from that. I am pasting the code that i have used to show the splash and the code from MainActivity. Please help me in reducing the startup time of the application. Splash.java @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_splash); txtLoad = (TextView) findViewById(R.id.txtLoading); txtLoad.setText("v1.0"); new Thread() { public void run() { try { sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } finally { finish(); Intent intent = new Intent(SplashActivity.this,MainActivity.class); startActivity(intent); } } }.start(); } MainActivity.java @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); editType1UserName = (EditText) findViewById(R.id.editTextType1UserName); editType1Password = (EditText) findViewById(R.id.editTextType1Password); editType2UserName = (EditText) findViewById(R.id.editTextType2UserName); editType2Password = (EditText) findViewById(R.id.editTextType2Password); editType3UserName = (EditText) findViewById(R.id.editTextType3UserName); editType3Password = (EditText) findViewById(R.id.editTextType3Password); editType4UserName = (EditText) findViewById(R.id.editTextType4UserName); editType4Password = (EditText) findViewById(R.id.editTextType4Password); mTxtPhoneNo = (AutoCompleteTextView) findViewById(R.id.mmWhoNo); mTxtPhoneNo.setThreshold(1); editText = (EditText) findViewById(R.id.editTextMessage); spinner1 = (Spinner) findViewById(R.id.spinnerGateway); btnsend = (Button) findViewById(R.id.btnSend); btnContact = (Button) findViewById(R.id.btnContact); btnsend.setOnClickListener((OnClickListener) this); btnContact.setOnClickListener((OnClickListener) this); mPeopleList = new ArrayList<Map<String, String>>(); PopulatePeopleList(); mAdapter = new SimpleAdapter(this, mPeopleList, R.layout.custcontview, new String[] { "Name", "Phone", "Type" }, new int[] { R.id.ccontName, R.id.ccontNo, R.id.ccontType }); mTxtPhoneNo.setAdapter(mAdapter); mTxtPhoneNo.setOnItemClickListener((OnItemClickListener) this); readPerson(); Panel panel; topPanel = panel = (Panel) findViewById(R.id.mytopPanel); panel.setOnPanelListener((OnPanelListener) this); panel.setInterpolator(new BounceInterpolator(Type.OUT)); getLoginDetails(); }

    Read the article

  • Android - passing data between Activities

    - by Bill Osuch
    (To follow along with this, you should understand the basics of starting new activities: Link ) The easiest way to pass data from one activity to another is to create your own custom bundle and pass it to your new class. First, create two new activities called Search and SearchResults (make sure you add the second one you create to the AndroidManifest.xml file!), and create xml layout files for each. Search's file should look like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical">     <TextView          android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:text="Name:"/>     <EditText                android:id="@+id/edittext"         android:layout_width="fill_parent"         android:layout_height="wrap_content"/>     <TextView          android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="ID Number:"/>     <EditText                android:id="@+id/edittext2"                android:layout_width="fill_parent"                android:layout_height="wrap_content"/>     <Button           android:id="@+id/btnSearch"          android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="Search" /> </LinearLayout> and SearchResult's should look like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical">     <TextView          android:id="@+id/txtName"         android:layout_width="fill_parent"         android:layout_height="wrap_content"/>     <TextView          android:id="@+id/txtState"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="No data"/> </LinearLayout> Next, we'll override the OnCreate method of Search: @Override public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.search);     Button search = (Button) findViewById(R.id.btnSearch);     search.setOnClickListener(new View.OnClickListener() {         public void onClick(View view) {                           Intent intent = new Intent(Search.this, SearchResults.class);              Bundle b = new Bundle();                           EditText txt1 = (EditText) findViewById(R.id.edittext);             EditText txt2 = (EditText) findViewById(R.id.edittext2);                                      b.putString("name", txt1.getText().toString());             b.putInt("state", Integer.parseInt(txt2.getText().toString()));                              //Add the set of extended data to the intent and start it             intent.putExtras(b);             startActivity(intent);          }     }); } This is very similar to the previous example, except here we're creating our own bundle, adding some key/value pairs to it, and adding it to the intent. Now, to retrieve the data, we just need to grab the Bundle that was passed to the new Activity and extract our values from it: @Override public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.search_results);     Bundle b = getIntent().getExtras();     int value = b.getInt("state", 0);     String name = b.getString("name");             TextView vw1 = (TextView) findViewById(R.id.txtName);     TextView vw2 = (TextView) findViewById(R.id.txtState);             vw1.setText("Name: " + name);     vw2.setText("State: " + String.valueOf(value)); }

    Read the article

  • Make my radio buttons become selected in Android

    - by NickTFried
    When I run this could and click on the dialog box my radiobuttons do not become selected like intended package edu.elon.cs.mobile; import edu.elon.cs.mobile.R; import edu.elon.cs.mobile.R.id; import edu.elon.cs.mobile.R.layout; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.text.Editable; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; import android.widget.TextView; import android.widget.Toast; public class PTCalculator extends Activity{ private RadioButton maleRadioButton; private RadioButton femaleRadioButton; private EditText ageEdit; private EditText pushUpsEdit; private EditText sitUpsEdit; private EditText mileMinEdit; private EditText mileSecEdit; private Button calculate; private TextView score; protected AlertDialog genderAlert; private int currScore; private int age; private int sitUps; private int runTime; private int pushUps; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pt); maleRadioButton = (RadioButton) findViewById(R.id.male); femaleRadioButton = (RadioButton) findViewById(R.id.female); ageEdit = (EditText) findViewById(R.id.ageEdit); pushUpsEdit = (EditText) findViewById(R.id.pushupEdit); sitUpsEdit = (EditText) findViewById(R.id.situpEdit); mileMinEdit = (EditText) findViewById(R.id.minEdit); mileSecEdit = (EditText) findViewById(R.id.secEdit); calculate = (Button) findViewById(R.id.calculateButton); calculate.setOnClickListener(calculateButtonListener); score = (TextView) findViewById(R.id.scoreView); genderAlert = makeGenderDialog().create(); } private OnClickListener calculateButtonListener = new OnClickListener() { @Override public void onClick(View arg0) { age = (Integer.parseInt(ageEdit.getText().toString())); pushUps = (Integer.parseInt(pushUpsEdit.getText().toString())); sitUps = (Integer.parseInt(sitUpsEdit.getText().toString())); int min = (Integer.parseInt(mileMinEdit.getText().toString())*60); int sec = (Integer.parseInt(mileSecEdit.getText().toString())); runTime = min + sec; if(maleRadioButton.isChecked()){ MalePTTest mPTTest = new MalePTTest(age, pushUps, sitUps, runTime); currScore = mPTTest.malePTScore(); score.setText((Integer.toString(currScore))); }else if(femaleRadioButton.isChecked()){ FemalePTTest fPTTest = new FemalePTTest(age, pushUps, sitUps, runTime); currScore = fPTTest.femalePTScore(); score.setText((Integer.toString(currScore))); }else genderAlert.show(); } }; public AlertDialog.Builder makeGenderDialog(){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Select a Gender") .setCancelable(false) .setPositiveButton("Female", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { femaleRadioButton.setSelected(true); FemalePTTest fPTTest = new FemalePTTest(age, pushUps, sitUps, runTime); currScore = fPTTest.femalePTScore(); score.setText((Integer.toString(currScore))); } }) .setNegativeButton("Male", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { maleRadioButton.setSelected(true); MalePTTest mPTTest = new MalePTTest(age, pushUps, sitUps, runTime); currScore = mPTTest.malePTScore(); score.setText((Integer.toString(currScore))); } }); return builder; } } Any suggestions?

    Read the article

  • Soft keyboard does not show when Activity starts

    - by Sarp Centel
    I have added android:windowSoftInputMode="stateAlwaysVisible" to my Activity in AndroidManifest.xml and here's my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <EditText android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText> <EditText android:id="@+id/EditText02" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText> <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Send"></Button> </LinearLayout> When the Activity starts, the EditText is focused, but soft keyboard isn't displayed. If I click on the EditText, then I see the soft keyboard. Do I need to set aditional parameters to display soft keyboard when my Activity starts? Thanks

    Read the article

  • Android Actionbar Tabs + Fragments + Service

    - by Vladimir
    So, I have 3 problems with my code: 1) I want that each tab saves its state. So that a TextView shows changed text if it was changed. 2) if I go to Tab2 then to Tab1 I can't see the content of the fragments. Only if I touch on the already selected tab, it shows me the content 3) I can't correctly connect/bind and unbind service to Fragment Text must be changed from Service. Please help, I don't know how I realize my intent. MyActivity.java package com.example.tabs; import android.app.ActionBar; import android.app.ActionBar.Tab; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.app.Fragment; import android.app.FragmentTransaction; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; public class MyActivity extends Activity { private static String ACTION_BAR_INDEX = "ACTION_BAR_INDEX"; private Tab tTab1; private Tab tTab2; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private TabListener<Tab1> tab1Listener; private TabListener<Tab2> tab2Listener; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { } } } }; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myServiceIntent = new Intent(this, MyService.class); bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); if (!isServiceRunning()) { startService(myServiceIntent); } final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); tTab1 = actionBar.newTab(); tab1Listener = new TabListener<Tab1>(this, R.id.fl_main, Tab1.class); tTab1.setTag("Tab_1"); tTab1.setText("Tab_1"); tTab1.setTabListener(tab1Listener); tTab2 = actionBar.newTab(); tab2Listener = new TabListener<Tab2>(this, R.id.fl_main, Tab2.class); tTab2.setTag("Tab_2"); tTab2.setText("Tab_2"); tTab2.setTabListener(tab2Listener); actionBar.addTab(tTab1, 0); actionBar.addTab(tTab2, 1); } @Override public void onResume() { super.onResume(); SharedPreferences sp = getPreferences(Activity.MODE_PRIVATE); int actionBarIndex = sp.getInt(ACTION_BAR_INDEX, 0); getActionBar().setSelectedNavigationItem(actionBarIndex); } protected void onSaveInstanceState(Bundle outState) { // Save the current Action Bar tab selection int actionBarIndex = getActionBar().getSelectedTab().getPosition(); SharedPreferences.Editor editor = getPreferences(Activity.MODE_PRIVATE).edit(); editor.putInt(ACTION_BAR_INDEX, actionBarIndex); editor.apply(); // Detach each of the Fragments FragmentTransaction ft = getFragmentManager().beginTransaction(); if (tab2Listener.fragment != null) { ft.detach(tab2Listener.fragment); } if (tab1Listener.fragment != null) { ft.detach(tab1Listener.fragment); } ft.commit(); super.onSaveInstanceState(outState); } protected void onRestoreInstanceState(Bundle savedInstanceState) { // Find the recreated Fragments and assign them to their associated Tab // Listeners. tab1Listener.fragment = getFragmentManager().findFragmentByTag(Tab1.class.getName()); tab2Listener.fragment = getFragmentManager().findFragmentByTag(Tab2.class.getName()); // Restore the previous Action Bar tab selection. SharedPreferences sp = getPreferences(Activity.MODE_PRIVATE); int actionBarIndex = sp.getInt(ACTION_BAR_INDEX, 0); getActionBar().setSelectedNavigationItem(actionBarIndex); super.onRestoreInstanceState(savedInstanceState); } public boolean isServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (MyService.class.getName().equals(service.service.getClassName())) { return true; } } return false; } @Override protected void onDestroy() { super.onDestroy(); unbindService(myConnection); stopService(myServiceIntent); } public static class TabListener<T extends Fragment> implements ActionBar.TabListener { private Fragment fragment; private Activity activity; private Class<T> fragmentClass; private int fragmentContainer; public TabListener(Activity activity, int fragmentContainer, Class<T> fragmentClass) { this.activity = activity; this.fragmentContainer = fragmentContainer; this.fragmentClass = fragmentClass; } public void onTabReselected(Tab tab, FragmentTransaction ft) { if (fragment != null) { ft.attach(fragment); } } public void onTabSelected(Tab tab, FragmentTransaction ft) { if (fragment == null) { String fragmentName = fragmentClass.getName(); fragment = Fragment.instantiate(activity, fragmentName); ft.add(fragmentContainer, fragment, fragmentName); } else { ft.detach(fragment); } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { if (fragment != null) { ft.detach(fragment); } } } } MyService.java package com.example.tabs; import android.app.Service; import android.content.Intent; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; public class MyService extends Service { private final IBinder myBinder = new MyBinder(); private static Handler myServiceHandler; public IBinder onBind(Intent intent) { return myBinder; } public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); return START_STICKY; } public void sendMessage(String sText, int id) { Bundle bundle = new Bundle(); bundle.putString("Text" + id, sText); Message bundleMessage = new Message(); bundleMessage.setData(bundle); myServiceHandler.sendMessage(bundleMessage); } public class MyBinder extends Binder { public MyService getService() { return MyService.this; } public void setCallbackHandler(Handler myActivityHandler) { myServiceHandler = myActivityHandler; } public void removeCallbackHandler() { myServiceHandler = null; } } } Tab1.java package com.example.tabs; import android.app.Activity; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Tab1 extends Fragment { public static String TAG = Tab1.class.getClass().getSimpleName(); private static TextView tvText; private EditText editText; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { tvText.setText(text); } } } }; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab1, container, false); tvText = (TextView) view.findViewById(R.id.tv_tab1); editText = (EditText) view.findViewById(R.id.editText1); Button btn1 = (Button) view.findViewById(R.id.btn_change_text_1); btn1.setOnClickListener(new OnClickListener() { public void onClick(View v) { myService.sendMessage(String.valueOf(editText.getText()), 1); } }); return view; } @Override public void onAttach(Activity activity) { super.onAttach(activity); myServiceIntent = new Intent(activity, MyService.class); activity.bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); } @Override public void onDetach() { super.onDetach(); getActivity().unbindService(myConnection); } } Tab2.java package com.example.tabs; import android.app.Activity; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Tab2 extends Fragment { public static String TAG = Tab2.class.getClass().getSimpleName(); private static TextView tvText; private EditText editText; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { tvText.setText(text); } } } }; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab2, container, false); tvText = (TextView) view.findViewById(R.id.tv_tab2); editText = (EditText) view.findViewById(R.id.editText2); Button btn2 = (Button) view.findViewById(R.id.btn_change_text_2); btn2.setOnClickListener(new OnClickListener() { public void onClick(View v) { myService.sendMessage(String.valueOf(editText.getText()), 2); } }); return view; } @Override public void onAttach(Activity activity) { super.onAttach(activity); myServiceIntent = new Intent(activity, MyService.class); activity.bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); } @Override public void onDetach() { super.onDetach(); getActivity().unbindService(myConnection); } } main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:orientation="vertical" > </LinearLayout> tab1.xml <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:layout_gravity="center" android:gravity="center" android:orientation="vertical" > <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <Button android:id="@+id/btn_change_text_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="Change text" /> <TextView android:id="@+id/tv_tab1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TAB1\nTAB1\nTAB1" /> </LinearLayout> tab2.xml <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:layout_gravity="center" android:gravity="center" android:orientation="vertical" > <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <Button android:id="@+id/btn_change_text_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="Change text" /> <TextView android:id="@+id/tv_tab2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="TAB2\nTAB2\nTAB2" /> </LinearLayout> AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tabs" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="TabsPlusService" android:theme="@android:style/Theme.Holo" > <activity android:name="com.example.tabs.MyActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="TabsPlusService" android:theme="@android:style/Theme.Holo" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name=".MyService" android:enabled="true" > </service> </application> </manifest>

    Read the article

  • android dynamical binding

    - by yoav.str
    I want to work dynamically therefore I want to bind text views dynamically I think an example would explain me the best assuming I want to bind 7 image views i can do it like this : Country = (EditText)findViewById(R.id.CountryEditText); City = (EditText)findViewById(R.id.CityEditText); LivinigCreture = (EditText)findViewById(R.id.LivingCretureE); Nature =(EditText)findViewById(R.id.NatureEditText); Inanimate = (EditText)findViewById(R.id.InanimateEditText); KnowenPersonality = (EditText)findViewById(R.id.KnowenPersonalityEditText); Occupation = (EditText)findViewById(R.id.OccupationEditText); but lets change 7 with NUMOFFILEDS as a final where i want to do the previous ? myImages = new ImageView [7]; for (int i = 0; i<7;i++,????) myImages[i] = (ImageView)findViewById(R.id.initialImageView01); notice : in my R file the R.id.initialImageView01 - R.id.initialImageView07 are not generate in a cont gap between them therefore I don't know how to make this architecture possible . and if there's a way can someone show me an example how to work dynmiclly (like using jsp on android combined way or something ?) id its possiable to do so constant times is it possible to build an the same xml constant num of times like jsp does thank u pep:)

    Read the article

  • how to changed editext values from first to last in customise listview in android

    - by prakash
    i am getting menunames from database then append to the custom listview edittext . now i am changing some values in edittext . i want all values with changed values of edittext into array Example :x,y,z menunames comes from database i append editext(Custom listview) now i am changed y to b now i want x,b,z in arraylist i try this code(Base adapter class) public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.editmainmenulist, null); holder.caption = (EditText) convertView .findViewById(R.id.editmaimenu); holder.caption1=(ImageView) convertView.findViewById(R.id.menuimage); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } //Fill EditText with the value you have in data source holder.caption.setText(itemnames[position]); holder.caption.setId(position); holder.caption1.setImageBitmap(bmps[position]); arr.add(holder.caption.getText().toString());//here i get menunames data only not changed edittext values return convertView; } } class ViewHolder { EditText caption; ImageView caption1; } class ListItem { String caption; } please help me

    Read the article

  • How to display data in TextView

    - by ranjanarr
    I have a view in which there is a text box where user enters data, when clicks on submit, I want to store the input and display in another box. final EditText edittext = (EditText) findViewById(R.id.edittext); mText = (TextView) findViewById(R.id.timepicker_input); How can I do it, please help

    Read the article

  • android alarm not able to launch alarm activity

    - by user965830
    I am new to android programming and am trying to make this simple alarm app. I have my code written and it is compiled with no errors. The app runs in the emulator, that is the main activity asks the date and time, but when i click on the confirm button, it displays the message - "Unfortunately, Timer1 has stopped working." The code for my main activity is as follows: public void onClick(View v) { EditText date = (EditText) findViewById(R.id.editDate); EditText month = (EditText) findViewById(R.id.editMonth); EditText hour = (EditText) findViewById(R.id.editHour); EditText min = (EditText) findViewById(R.id.editMin); int dt = Integer.parseInt(date.getText().toString()); int mon = Integer.parseInt(month.getText().toString()); int hr = Integer.parseInt(hour.getText().toString()); int mnt = Integer.parseInt(min.getText().toString()); Intent myIntent = new Intent(MainActivity.this, AlarmActivity.class); pendingIntent = PendingIntent.getService(MainActivity.this, 0, myIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DATE, dt); calendar.set(Calendar.MONTH, mon); calendar.set(Calendar.HOUR, hr); calendar.set(Calendar.MINUTE, mnt); alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent); } I do not understand what all the errors in logcat mean, so i am posting them: 06-25 16:03:32.175: I/Process(566): Sending signal. PID: 566 SIG: 9 06-25 16:03:53.775: I/dalvikvm(612): threadid=3: reacting to signal 3 06-25 16:03:54.046: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt' 06-25 16:03:54.255: I/dalvikvm(612): threadid=3: reacting to signal 3 06-25 16:03:54.305: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt' 06-25 16:03:54.735: I/dalvikvm(612): threadid=3: reacting to signal 3 06-25 16:03:54.785: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt' 06-25 16:03:54.925: D/gralloc_goldfish(612): Emulator without GPU emulation detected. 06-25 16:05:09.605: D/AndroidRuntime(612): Shutting down VM 06-25 16:05:09.605: W/dalvikvm(612): threadid=1: thread exiting with uncaught exception (group=0x409c01f8) 06-25 16:05:09.685: E/AndroidRuntime(612): FATAL EXCEPTION: main 06-25 16:05:09.685: E/AndroidRuntime(612): java.lang.NumberFormatException: Invalid int: "android.widget.EditText@41030b40" 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.Integer.invalidInt(Integer.java:138) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.Integer.parse(Integer.java:375) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.Integer.parseInt(Integer.java:366) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.Integer.parseInt(Integer.java:332) 06-25 16:05:09.685: E/AndroidRuntime(612): at com.kapymay.tversion1.MainActivity$1.onClick(MainActivity.java:34) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.view.View.performClick(View.java:3511) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.view.View$PerformClick.run(View.java:14105) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.os.Handler.handleCallback(Handler.java:605) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.os.Handler.dispatchMessage(Handler.java:92) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.os.Looper.loop(Looper.java:137) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.app.ActivityThread.main(ActivityThread.java:4424) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.reflect.Method.invokeNative(Native Method) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.reflect.Method.invoke(Method.java:511) 06-25 16:05:09.685: E/AndroidRuntime(612): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 06-25 16:05:09.685: E/AndroidRuntime(612): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 06-25 16:05:09.685: E/AndroidRuntime(612): at dalvik.system.NativeStart.main(Native Method) 06-25 16:05:10.445: I/dalvikvm(612): threadid=3: reacting to signal 3 06-25 16:05:10.575: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt'

    Read the article

  • Proportional width of elements in LinearLayout

    - by Laimoncijus
    I have a horizontal LinearLayout and in it I have EditText and Spinner elements. Which attributes I need to adjust so I would get proportional widths: I want EditText to take 3/5 and Spinner - 2/5 of all available width? My code looks like this: <LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/LinearLayout01"> <EditText android:layout_height="wrap_content" android:id="@+id/EditText01" android:singleLine="true"> </EditText> <Spinner android:layout_height="wrap_content" android:id="@+id/Spinner01" android:layout_width="wrap_content"> </Spinner> </LinearLayout> I tried setting android:layout_weight, but somehow it does not look "stable" enough for me - when EditText has no text - everything looks fine, but as soon as I start entering text into it - it starts expanding and Spinner shrinking accordingly...

    Read the article

  • Android Dev: The constructor Intent(new View.OnClickListener(){}, Class<DrinksTwitter>) is undefined

    - by Malcolm Woods Spark
    package com.android.drinksonme; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Screen2 extends Activity { // Declare our Views, so we can access them later private EditText etUsername; private EditText etPassword; private Button btnLogin; private Button btnSignUp; private TextView lblResult; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get the EditText and Button References etUsername = (EditText)findViewById(R.id.username); etPassword = (EditText)findViewById(R.id.password); btnLogin = (Button)findViewById(R.id.login_button); btnSignUp = (Button)findViewById(R.id.signup_button); lblResult = (TextView)findViewById(R.id.result); // Set Click Listener btnLogin.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Check Login String username = etUsername.getText().toString(); String password = etPassword.getText().toString(); if(username.equals("test") && password.equals("test")){ final Intent i = new Intent(this, DrinksTwitter.class); //error on this line startActivity(i); // lblResult.setText("Login successful."); } else { lblResult.setText("Invalid username or password."); } } }); final Intent k = new Intent(Screen2.this, SignUp.class); btnSignUp.setOnClickListener(new OnClickListener() { public void onClick(View v) { startActivity(k); } }); } }

    Read the article

  • How to show virtual keypad in an android activity

    - by Maxood
    Why am i not able to show the virtual keyboard in my activity. Here is my code: package som.android.keypad; import android.app.Activity; import android.os.Bundle; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; public class ShowKeypad extends Activity { InputMethodManager imm; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); EditText editText = (EditText)findViewById(R.id.EditText); ((InputMethodManager) getSystemService(this.INPUT_METHOD_SERVICE)).showSoftInput(editText, 0); } } <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="som.android.keypad" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".ShowKeypad" android:windowSoftInputMode="stateAlwaysVisible" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="4" /> </manifest>

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >