Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development > Application Requests

Application Requests Request Apps or provide ideas for the devs here.



Reply
 
LinkBack Thread Tools
Old May 31st, 2011, 04:18 AM   #1 (permalink)
New Member
 
Join Date: May 2011
Posts: 4
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Laugh Gallery with wallpapers

Hi,

I am having a bit of trouble creating what I think should be a pretty simple app. Here's the description:

The app will look like a gallery of 4-7 images. The user can see and scroll through these images and choose any one of them as his phone's wallpaper by pressing a button on the bottom of the page.

Implementation 1: as a grid of the images. The user then "clicks" on an image to view a larger version of it, and also gets the "Set as Wallpaper" button.
Implementation 2: the top of the screen contains small versions of the images, like a scrollable gallery. The lower part of the screen contains the photo which is now selected and at the bottom there is the "Set Wallpaper" button.
Implementation 3: the images can be positioned 1 below the other at about 50% of their size and under each image there will be a "Set Wallpaper" button. This is not the most elegant but I think it's the easiest way.

I would really appreciate it if someone could give me some tips about how i could achieve any of these implementations.

PS: the app will be free on the market and used to promote my company at a trade show.

Thank you!

Fenyx is offline  
Reply With Quote
Sponsors
Old May 31st, 2011, 09:44 AM   #2 (permalink)
New Member
 
Join Date: May 2011
Posts: 4
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, figured out the gallery part, and the button part, now I just need to figure out how to make the button set the currently viewed image as the wallpaper.

Here's the code:

Code:
package com.example.hellogallery;

import java.io.IOException;

import android.app.Activity;
import android.app.WallpaperManager;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;

public class HelloGallery extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);

   Gallery g = (Gallery) findViewById(R.id.gallery);
   g.setAdapter(new ImageAdapter(this));

   Button buttonSetWallpaper = (Button)findViewById(R.id.set);
   
   buttonSetWallpaper.setOnClickListener(new Button.OnClickListener(){

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			WallpaperManager myWallpaperManager 
				= WallpaperManager.getInstance(getApplicationContext());
			try {
				myWallpaperManager.setResource(R.drawable.image_01);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}});
}

public class ImageAdapter extends BaseAdapter {
   int mGalleryItemBackground;
   private Context mContext;

   private Integer[] mImageIds = {
           R.drawable.image_01,
           R.drawable.image_02,
           R.drawable.image_03,
           R.drawable.image_04,
           R.drawable.image_05
   };

   public ImageAdapter(Context c) {
       mContext = c;
       TypedArray a = obtainStyledAttributes(R.styleable.Theme);
       mGalleryItemBackground = a.getResourceId(
         R.styleable.Theme_android_galleryItemBackground,
                   0);
       a.recycle();
   }

   public int getCount() {
       return mImageIds.length;
   }

   public Object getItem(int position) {
       return position;
   }

   public long getItemId(int position) {
       return position;
   }

   public View getView(int position,
       View convertView, ViewGroup parent) {
       ImageView i = new ImageView(mContext);

       i.setImageResource(mImageIds[position]);
       i.setLayoutParams(new Gallery.LayoutParams(384, 320));
       i.setScaleType(ImageView.ScaleType.FIT_XY);
       i.setBackgroundResource(mGalleryItemBackground);

       return i;
   }
}
}
Now I only need to figure out what to replace the R.drawable.image_01 with, so it selects the currently viewed image as the wallpaper.

PS: i basically stitched together 2 programs so I might have gotten it wrong or there may be an easier way to do it.

Please help
Fenyx is offline  
Reply With Quote
Old May 31st, 2011, 03:45 PM   #3 (permalink)
ROM Developer
 
cr5315's Avatar
 
Join Date: Jul 2010
Location: Narnia
Posts: 397
 
Device(s): Current: HTC Evo Retired: LG Ally
Thanks: 94
Thanked 142 Times in 93 Posts
Default

Application Requests isn't the place for this question. You'd get much better results in Application Development or Developer 101.
__________________

(That's a link. Just saying.)
cr5315 is offline  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development > Application Requests User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 03:03 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo