Android Open Source - android-single-child-layout Main Activity






From Project

Back to project page android-single-child-layout.

License

The source code is released under:

Apache License

If you think the Android project android-single-child-layout listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.github.curioustechizen.scl.sample;
/* w  w  w.j av  a2 s .  com*/
import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import com.github.curioustechizen.scl.SingleChildLayout;

public class MainActivity extends Activity {
    
    private SingleChildLayout mSingleChildLayout;
    int currentlyShowing;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mSingleChildLayout = (SingleChildLayout)findViewById(R.id.SingleChildLayout1);
        currentlyShowing = mSingleChildLayout.getShownChildIndex();
    }

   public void onButtonClick(View v){
       if(v.getId() == R.id.button1){
           changeToNextState();
       }
   }

   private void changeToNextState(){
       currentlyShowing = (currentlyShowing + 1) % mSingleChildLayout.getChildCount();
       mSingleChildLayout.showChildAt(currentlyShowing);
   }
}




Java Source Code List

com.github.curioustechizen.scl.SingleChildLayout.java
com.github.curioustechizen.scl.listsample.MainActivity.java
com.github.curioustechizen.scl.sample.MainActivity.java