ToRaRo
ToRaRo

Reputation: 611

How to start activity in another activity in android?

Im trying to make a simple card scanning in my activity. There is a problem that i need to start this scannong activity in another. There is a place (rectangle field) in the main activity. And i'm trying to start another activity only in that field.

So i don't know how to make two activities work in the same time on the same screen. That's the problem

Upvotes: 0

Views: 94

Answers (2)

Kevin van Mierlo
Kevin van Mierlo

Reputation: 9794

The best way to do this is to use fragments like @Raghunandan said.

You can just place a fragment in the place you have left.

Here is the link to the official Android site: http://developer.android.com/reference/android/app/Fragment.html

Here is the link @Swedish Architect gave: http://www.vogella.com/tutorials/AndroidFragments/article.html#fragments_tutorial

This is a really good tutorial on how to use fragments.

Fragments work almost like activities do.

Upvotes: 1

Shyam
Shyam

Reputation: 6434

you can't have multiple Activities on screen at once. However, you could refactor your separate activities into Views, then show a single Activity with one persistent View alongside a group of swappable Views (managed by tabs or ViewFlipper).

or

  • you can use Fragment
  • Custom dialog

    public class CustomDialog extends Dialog {

    public CustomDialog (Context context) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }
    

    }

Upvotes: 0

Related Questions