Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is my solution. I just give you the basic one. Create a <code>TextView</code> in front of <code>EditText</code> and two <code>Button</code> <code>OK</code>,<code>Cancel</code> (You can change to <code>ImageButton</code> like Skype). Change the visiblity of two view. The code is so simple without comment. You can add some null checking according your logic. </p> <pre><code>public class CompoundTextView extends RelativeLayout implements OnClickListener { private EditText edt; private TextView txt; RelativeLayout layout; public SkypeTextView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override protected void onFinishInflate() { super.onFinishInflate(); edt = (EditText) findViewById(R.id.edt); txt = (TextView) findViewById(R.id.txt_name); layout = (RelativeLayout) findViewById(R.id.layout); Button ok = (Button) findViewById(R.id.ok_btn); Button cancel = (Button) findViewById(R.id.cancel_btn); ok.setOnClickListener(this); cancel.setOnClickListener(this); txt.setOnClickListener(this); } public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.ok_btn: String editString = edt.getText().toString(); txt.setText(editString); layout.setVisibility(View.INVISIBLE); txt.setVisibility(View.VISIBLE); break; case R.id.cancel_btn: layout.setVisibility(View.INVISIBLE); txt.setVisibility(View.VISIBLE); break; case R.id.txt_name: txt.setVisibility(View.INVISIBLE); layout.setVisibility(View.VISIBLE); break; } } </code></pre> <p>}</p> <p>Create a XML <code>skypetextview</code>. You can customize font and background to make it's prettier.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; </code></pre> <p></p> <pre><code>&lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TextView android:id="@+id/txt_name" android:layout_width="fill_parent" android:layout_height="100dp" android:textColor="#FFFFFF" android:textSize="14sp" android:background="#ff0000" /&gt; &lt;RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="invisible" android:id="@+id/layout" &gt; &lt;EditText android:id="@+id/edt" android:layout_width="270dp" android:layout_height="100dp" /&gt; &lt;Button android:id="@+id/ok_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/edt" android:text="OK" /&gt; &lt;Button android:id="@+id/cancel_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/ok_btn" android:layout_toRightOf="@id/edt" android:text="Cancel" /&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p></p> <p>add (or include) this view to the layout you want. Example : </p> <pre><code>public class TestActivity extends Activity { SkypeTextView test; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater inflate = getLayoutInflater(); test = (SkypeTextView ) inflate.inflate(R.layout.compound_text_view, null); setContentView(test); } </code></pre> <p>PS: i forgot. You should add some <code>underline</code> format for your textview in order to make user notice it clickable</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload