0

I am developing an Fitness App. My app will have different exercises like Push Ups and Sit Ups. Every exercise need to have an image to show to the user. I have been thinking a while on what is a good way to solve this problem. But I don't think my solution below is good. Have you worked with images on Android for displaying images? Give me your solution on how you did it.

An exercise have a name but also images. The purpose is to display a specific Exercise with the images and exercise name.

My Exercise class looks like this right now: I have thought of having the path to the image saved which I can have access when I need to show the image. I am uploading the images on the assets folder.

public class Exercise {
     private String exerciseName;
     private String exerciseSmallImagePath;
     private String exerciseLargeImagePath;

public Exercise(String exerciseName, String exerciseSmallImagePath, String exerciseLargeImagePath){
    this.exerciseName = exerciseName;
    this.exerciseSmallImagePath = exerciseSmallImagePath;
    this.exerciseLargeImagePath = exerciseLargeImagePath;
    }
}
4
  • 1
    Create an activity and change an ImageView's image based on the name of the excersice. I suggest just adding the images to the resources folder so you can access them the way you should. Commented Mar 26, 2014 at 9:39
  • so are u facing any issue with your current implementation ? Commented Mar 26, 2014 at 9:40
  • 1
    Have you worked with images on Android for displaying images? this made my day :D //What issues are you having with images? Commented Mar 26, 2014 at 9:43
  • Is it a good to save the exercise name and image path? Or should I name the image so I know from the image name which exercise it is? Commented Mar 26, 2014 at 9:58

2 Answers 2

1

saving the path to the image-source is definitly a good approach. Have a look at ImageViews in order to display your image. There are two approaches to implement such an ImageView:

1: define it in your XML and set the image-source afterwards in your oncreate-method:

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Some description" />

2: define your ImageView programmatically in your Activity:

ImageView imageView = new ImageView(this);
LinearLayout.LayoutParams vp = 
    new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 
                    LayoutParams.WRAP_CONTENT);
imageView.setLayoutParams(vp);        
imageView.setImageResource(fetch your ID here);        
someLinearLayout.addView(imageView); 
Sign up to request clarification or add additional context in comments.

Comments

1

I suppose you are familiar with how to create simple application in Android? If not, then you should get started with samples and reading up on Android developers guide

This article can give you good start in how to work with Images.

As for how you should accomplish this, I can only suggest one approach, the rest is upto your imagination. Start with creating a fragment that has an image and a text below (or above if you like) it. You can then put this fragment where you want with new image and text. Here is a rough idea

<LinearLayout (vertical orientation>
 <Image ... />
 <Text ... />
</LinearLayout>

Once the layout is in place you can set the image source at runtime.

A good way to display this information is to have steps which user can navigate using swiping (view pager).

Every page can have the above mentioned fragment that will show one step. This will result in cleaner, slide screen style guide.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.