Skip to main content

Posts

Showing posts with the label activity

How to start or open new activity or window from one window on button click

Requirement: You want to make an "app", which displays a login screen, and users can log in. If the login is correct,  open a new window, where users can do other staff. Then how can you do this? Ans: Step 1. Create a layout xml for the new window. In my case I have created one named newwindow.xml . The entry are as follows -- <?xml version="1.0" encoding="utf-8"?> <Gallery xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#9999FF" >    </Gallery> Step 2. Create a class with extending Activity . Step 3. On that new class add -- public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.newwindow);     } Here newwindow is the lay...

How to add button action for multiple button in android

In android it is extreme necessary to use button and do many thing on click or touch of this button. So how you can do this ? Ans:   It's pretty simple! Just find out the -- findViewById(R.id.dummy_button).setOnTouchListener( mDelayHideTouchListener ); It is generated by default in new android sdk. The bold portion is the touch listener for button which is implemented on bellow of your main activity class. You can do your thing on overriden function OnTouch . If you want to do it for click and many button here is the way -- findViewById(R.id.dummy_button).setOnClickListener( ButtonListener ); View.OnClickListener ButtonListener = new View.OnClickListener(){         public void onClick(View view) {             switch (view.getId()) {                 case R.id.dummy_button:     ...