0

Hi I have this code to move from firstActvivity to secondActivity

try {
     Class ourClass = Class.forName("com.example.listexample.SecondActivity");
     forTransferIntent = new Intent(FirstActivity.this, ourClass);
     startActivity(forTransferIntent);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

I want to open my whole class in a popup that contains a button of OK and Cancel and a textfield to extract data from. most popup I have seen are just informative. I am looking for a popup that I can create fields into. Thanks!

MilapTank
  • 9,988
  • 7
  • 38
  • 53
Joseph
  • 69
  • 4
  • 13
  • 1
    http://stackoverflow.com/questions/1979369/android-activity-as-a-dialog – Shayan Pourvatan Jun 07 '14 at 04:48
  • Not an answer but why on earth are you doing this... `Class ourClass = Class.forName("com.example.listexample.SecondActivity");` – Squonk Jun 07 '14 at 04:53
  • To transfer to anther screen. It it bad? Any help is appreciated – Joseph Jun 07 '14 at 04:57
  • 1
    you can create your intent with : `Intent intent = new Intent( context , SecondActivity.class );` – Shayan Pourvatan Jun 07 '14 at 04:59
  • @Joseph : If you know the `Activity` name all you have to do is `forTransferIntent = new Intent(FirstActivity.this, SecondActivity.class);`. That's a standard way to start an `Activity` with an explicit `Intent`. – Squonk Jun 07 '14 at 05:00

1 Answers1

0

You need to create custom dialog for it (to show activity in a popup)

step 1) create a layout with proper id's.

step 2) use the following code wherever you desire.

LayoutInflater factory = LayoutInflater.from(this);
final View deleteDialogView = factory.inflate(
        R.layout.mylayout, null);
final AlertDialog deleteDialog = new AlertDialog.Builder(this).create();
deleteDialog.setView(deleteDialogView);
deleteDialogView.findViewById(R.id.yes).setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        //your business logic 
        deleteDialog.dismiss();
    }
});
deleteDialogView.findViewById(R.id.no).setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        deleteDialog.dismiss();

    }
});

deleteDialog.show();

3) in your mylayout use textview/edittext as you wish.(yes button here is your OK button) hopefully this solves your problem.

Swapnil Kadam
  • 4,075
  • 5
  • 29
  • 35