Showing posts with label Grid. Show all posts
Showing posts with label Grid. Show all posts

Monday, 12 October 2015

Help with grid View



Hello!
i need some help, i am creating a Grid View with this java code:

MainActivity

Quote:









public class MainActivity extends AppCompatActivity {

private GridView gridView;

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

gridView = (GridView)findViewById(R.id.gridview);
gridView.setAdapter(new GridAdapter(this));
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}




Product

Quote:









public class Product {

private static String nombrePizza;
private static String ingredientesPizza;
private static int imagenPizza;
private static int idThumbnail;

public Product(String nombrePizza, String ingredientesPizza, int imagenPizza){
this.nombrePizza = nombrePizza;
this.ingredientesPizza = ingredientesPizza;
this.imagenPizza = imagenPizza;
}

public String getNombrePizza(){return nombrePizza;}
public String getIngredientesPizza(){return ingredientesPizza;}
public int getImagenPizza(){return imagenPizza;}
public int getId(){return nombrePizza.hashCode();}

public static Product[] Pizzas={
new Product(
"Proscuito",
"Jamon York y queso",
R.drawable.imagenprueba),
new Product(
"Tropical",
"Jamon York, queso y piña",
R.drawable.imagenprueba),
new Product(
"Barbacoa",
"Carne picada, queso y salsa Barbacoa",
R.drawable.imagenprueba),
new Product(
"Romana",
"Jamon York, champiñones y queso",
R.drawable.cubo),
};

public static Product getItem(int id) {
for (Product item : Pizzas) {
if (item.getId() == id) {
return item;
}
}
return null;
}

}




Grid Adapter

Quote:









public class GridAdapter extends BaseAdapter {

private final Context mContext;

public GridAdapter(Context c){
this.mContext = c;
}

@Override
public int getCount(){return Product.Pizzas.length;}

@Override
public Product getItem(int position){return Product.Pizzas[position];}

@Override
public long getItemId(int position){return 0;}

@Override
public View getView(int position, View ConvertView, ViewGroup viewGroup){


if(ConvertView == null){
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_ SERVICE);
ConvertView = inflater.inflate(R.layout.grid_item, viewGroup, false);
}

TextView name = (TextView)ConvertView.findViewById(R.id.grid_mainT ext);
ImageView image = (ImageView) ConvertView.findViewById(R.id.grid_image);
TextView descripcion = (TextView) ConvertView.findViewById(R.id.grid_subText);

final Product item = getItem(position);

image.setImageResource(item.getImagenPizza());
name.setText(item.getNombrePizza());
descripcion.setText(item.getIngredientesPizza());

return ConvertView;
}
}




It work fine except for one thing, the app only shows the last product of the java code (Pizza romana)four times :eek:

I dont know why my app do this, can somebody help me??
Thank you! :fingers-crossed:



Sunday, 11 October 2015

Program to put a cm/mm grid over a picture and/or ruler next to it.



Hi;

I take pictures with my S5 of body lesions,etc.

IS there a way to apply a circular grid over the picture and when I take the picture to show the dimensions in mm/cm?
Also, to be able to have a mm/cm ruler next to the lesion when I take it.
Thank you.



Thursday, 8 October 2015

Visible digitizer grid



Even indoors, if the screen gets hit with direct light, there is a clearly visible crosshatch pattern across the whole display. Anyone else notice this?

Got to say I'm not too impressed with the screen quality. Light bleed, dead pixels and now this. My much cheaper Redmi 1s has none of these issues. Sure, the colours aren't as vibrant but not sure which I'd choose given the choice.