开发者

clicking on plus button produces a new edittext in the same view

I am developing an android contacts based application.I have designed the views.I am in problem.When i click on plus button a edittext should appear in the same view Can anyone help me

My java code is

package com.xib;

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;

public class FirstScreen extends Activity {
    private Button Back;
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_screen);

        Back = (Button)findViewById(R.id.back_btn1);
        Back.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View v)
            {

                Intent intent = new Intent(FirstScreen.this,SecondScreen.class);
                startActivity(intent);


            }


    });
    }
}

And my Xml is

<EditText
     android:id="@+id/edit2"
     android:hint=""
     android:singleLine="true"
     android:layout_marginLeft="50px"
     android:layout_width="192px"
     android:layout_height="wrap_content"/>

开发者_StackOverflow

Thanks in advance Tushar


I think his problem is adding dynamic view to his current activity means when the user clicks on plus button, may be he want to add dynamic edit text to his activity. For example in the android contacts while adding new contact there is a plus button whenever we click on that edittext will be added dynamically there so that we can add more contact numbers of a person like mobile, home etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜