Android Open Source - RatioImageView Main Activity






From Project

Back to project page RatioImageView.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project RatioImageView 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.alimuzaffar.ratioimageview.demo;
/*  ww  w.  j a  va2s.  c om*/
import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class MainActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    RadioGroup radios = (RadioGroup) findViewById(R.id.options);
    radios.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      
      @Override
      public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
        case R.id.ratio:
          setupGrid(R.layout.grid_item_ratio);
          break;
        case R.id.scale:
          setupGrid(R.layout.grid_item_scale);    
          break;
        default:
          setupGrid(R.layout.grid_item);  
          break;
        }
      }
    });

    setupGrid(R.layout.grid_item);

  }

  private void setupGrid(int layoutResId) {
    ArrayAdapterItem adapter = new ArrayAdapterItem(this,
        layoutResId, new String[] { "property_1.jpg",
            "property_2.jpg", "property_3.jpg", "property_4.jpg", "property_1.jpg",
            "property_2.jpg", "property_3.jpg", "property_4.jpg", "property_1.jpg",
            "property_2.jpg", "property_3.jpg", "property_4.jpg", "property_1.jpg",
            "property_2.jpg", "property_3.jpg", "property_4.jpg", "property_1.jpg",
            "property_2.jpg", "property_3.jpg", "property_4.jpg", "property_1.jpg",
            "property_2.jpg", "property_3.jpg", "property_4.jpg", "property_1.jpg",
            "property_2.jpg", "property_3.jpg", "property_4.jpg", "property_1.jpg",
            "property_2.jpg", "property_3.jpg", "property_4.jpg", "land_highres_1.jpg", "land_highres_2.png", "port_highres_1.jpg", "port_highres_2.png"});

    GridView grid = (GridView) findViewById(R.id.gridview);
    grid.setAdapter(adapter);
    adapter.notifyDataSetChanged();

  }
}




Java Source Code List

com.alimuzaffar.ratioimageview.RatioImageView.java
com.alimuzaffar.ratioimageview.demo.ArrayAdapterItem.java
com.alimuzaffar.ratioimageview.demo.MainActivity.java