Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6651243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:59:16+00:00 2026-05-26T00:59:16+00:00

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new

  • 0
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button button1 = (Button) findViewById(R.id.button1);
    button1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            EditText nameText = (EditText) findViewById(R.id.editText1);
            name = nameText.getText().toString();
            nameText.setText("");
            EditText numberText = (EditText) findViewById(R.id.editText2);
            number = numberText.getText().toString();
            numberText.setText("");
            person = new Person(name, number);
            order.add(person);

            PersonAdapter pa = new PersonAdapter(con, R.layout.row, order);
            setListAdapter(pa);
        }
    });
}

@Override
protected void onListItemClick(ListView l, View v, final int position, long id) {
    // TODO Auto-generated method stub
    final int index = position;
    AlertDialog.Builder aDialog = new AlertDialog.Builder(this);
    aDialog.setTitle("What do you want??");
    aDialog.setPositiveButton("Delete",
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    order.remove(index);
                    PersonAdapter pa = new PersonAdapter(con, R.layout.row,
                            order);
                    setListAdapter(pa);
                }
            });

    aDialog.setNeutralButton("Edit", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub

            LayoutInflater inflater = (LayoutInflater) con.getSystemService(LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.custom_dialog, (ViewGroup)findViewById(R.id.root_layout));
            builder = new AlertDialog.Builder(con);
            builder.setView(layout);
            builder.setTitle("Fill EditText");
            builder.setIcon(R.drawable.icon);
            editNum = (EditText)findViewById(R.id.editNum);
            editName = (EditText)findViewById(R.id.editName);
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                    name = editName.getText().toString();
                    number = editNum.getText().toString();

                    order.set(position, new Person(name,number));

                    PersonAdapter pa = new PersonAdapter(con, R.layout.row, order);
                    setListAdapter(pa);
                }
            });

            builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }
            });

            alertDialog = builder.create();
            alertDialog.show();

        }
    });

    aDialog.setNegativeButton("Cancel",
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                }
            });
    AlertDialog ad = aDialog.create();
    ad.show();
}


public PersonAdapter(Context context, int textViewResourceId,
        ArrayList<Person> items) {
    super(context, textViewResourceId, items);
    this.items = items;
}

public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.row, null);
    }

    Person p = items.get(position);
    if (p != null) {
        TextView tt = (TextView) v.findViewById(R.id.android_toptext);
        TextView bt = (TextView) v.findViewById(R.id.android_bottomtext);
        if (tt != null) {
            tt.setText(p.getName());
        }
        if (bt != null) {
            bt.setText("TEL : " + p.getNumber());
        }
    }
    return v;
}

private String name;
private String number;

public Person(String name, String number) {
    this.name = name;
    this.number = number;
}

public String getName() {
    return name;
}

public String getNumber() {
    return number;
}

}

I am practicing Widget(exactly I am making custom dialog) and Listener In android . But I stop now because “.getText().toString();” makes error … I can’t understand.. T^T Please Help me… why it makes error?? I think It doesn’t have problem

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:59:16+00:00Added an answer on May 26, 2026 at 12:59 am

    You should declare your EditText globally

    EditText editName; 
    EditText editNum;
    
    @Override
        public void onCreate(Bundle savedInstanceState) {
    ...
    }
    

    …..

     @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
    
                LayoutInflater inflater = (LayoutInflater) con.getSystemService(LAYOUT_INFLATER_SERVICE);
                View layout = inflater.inflate(R.layout.custom_dialog, (ViewGroup)findViewById(R.id.root_layout));
                builder = new AlertDialog.Builder(con);
                builder.setView(layout);
                builder.setTitle("Fill EditText modificated");
                builder.setIcon(R.drawable.icon);
                editName = (EditText)findViewById(R.id.editName);
                editNum = (EditText)findViewById(R.id.editNum);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextView = (TextView) findViewById(R.id.text); new Thread(new
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // mEditor=(TextView)findViewById(R.id.text); } @Override public boolean
String[] items = new String[10]; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //
I tried to do this @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); t=new
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.e(SMS,Hello World); //not showing Log.v(SMS,Hello World);
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ThraedDemo objDemo = new ThraedDemo(); Thread
My code looks as follows.. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try
Here is my main: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LinearLayout layout
I have this code : @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); db = new DbAdapter(getBaseContext()); db.open(); android_id =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.