package com.example.custom.edit.text; import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout;
public class CustomEditTextActivity extends Activity { public static class CustomEditText extends EditText { public CustomEditText(Context context) { super(context); setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // TODO This isn't called till we setFocusableInTouchMode(false) ((CustomEditText) arg0).setText("SELECTED"); } }); setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View arg0) { // TODO request focus and show soft keyboard if necessary return false; } }); } // TODO save this so that some listener can // restore it to NORMAL state private static CustomEditText mLastTapped; } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); CustomEditText cet; for (int i = 0; i < 5; i++) { cet = new CustomEditText(this); cet.setText("NORMAL STATE"); cet.setBackgroundColor(Color.WHITE); cet.setSelectAllOnFocus(true); layout.addView(cet, new LinearLayout.LayoutParams(-1, -1, 1)); } setContentView(layout); } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en