How to change ImageView content in layout? - Android Software Development

Hi,
in my simple app i have an activity with some textviews and a single imageview.
I'm trying to understand how to dynamically change the content of the imageview in my linear layout. I have a linearlayout and i only need to change the image in it (based on the logic of the underlying application) and similarly the text of the textviews. The pictures are .png files that i have put in res/drawable.
It seems to me that the only way is to use an adapter (simpleadapter) but i struggle to find an example of source code as all the ones i found so far refer to more complex adapters (e.g. simplecursoradapter). Anyway i'm very new to these concepts (adapters, helpers, etc.).
Do i really need to define and use AdapterView (or a more specific subclass?) or if if i keep the image files in res/drawable there is a more straightforward way to dynamically change the ImageView?
Thanks in advance,
x70

ImageView iv = (ImageView)findViewById(R.id.myimageview);
iv.setImageResource(resId);
where resId = R.drawable.mypng
With the textviews is similar, just call setText.

Thanks a lot janfsd. That was really easy...
I did actually try before in that way but i thought i needed also to explicitly set the view (eg via setContentView) and it didnt work; i didn't realise that there is no need for that.
still its not clear to me when do i need to use setContentView, but i made good progress!
Cheers,
x70

setContentView is normally used to set the layout(View) of the activity. I have only used it once per activity. Unless you want to change all the Layout of the activity then don't use it more than once, only on the onCreate method after the super call.
So you should only need to use setSomething method which each view should have it.

Related

event handling in dynamically created control

Hi all,
I am using eVC++ 4.0, and i've dynamically created a CListView like this:
Code:
lv.Create(0,_T(""),WS_CHILD|WS_VISIBLE,r,this,5);
but I dont know how to handle the events of this control... any ideas??
Mohammad
To get events from a listview (win32) I normally subclass it. I use the subclassing routine to post a message back to the parent when the user is doing something like tapping on it, then the windows routine can check whats selected etc and act on it. Is subclassing possible in mfc ?( I don't use it).
Thank u
but can anybody post some code??
thnx
Ok, I am a bit lazy to look up code at the moment, but here's something:
Yes, subclassing is possible in MFC. You just derive your class from the basic class provided like this:
Code:
class MyListView : pubic CListView
Then you add message handlers in the normal matter.
EDIT: The following passage is incorrect:
But I think subclassing may not be necessary in you case. List box controls send WM_COMMAND messages with notifications of major events like selection change to the parent window. All you have to do is to create a WM_COMMAND handler in your parent class.
Sorry I was thinking of ListBox not list view when I wrote it.
To manually add message handlers you need to put macros like ON_MESAGE or ON_COMMAND in the DECLARE_MESSAGE_MAP section of the class cpp file. All the detaisl are available on MSDN.
Are you saying that a listview will send the same WM_COMMAND as a list box in mfc? Dose this also happen in win32 made listviews. I have always thought it was a bit too tedious to find out when the user taps an item in the listview.
After reading your post levenum I had a quick look and it says that a WM_NOTIFY gets sent to the parent with a LVN_ITEMCHANGED for example. I had not used the LVN_**** because when I looked at them there was none that seem to deal with selections. I would guess that LVN_ITEMACTIVATE or LVN_ODSTATECHANGED would be usefull for this but then a second tap would not be picked up still leaving me wanting subclassing in many situations to get the users tap.
Ok, I have read what u wrote guys and my problem is almost solved, I used the OnNotify() method to handle messages sent from child controls like this:
Code:
BOOL CTest2Dlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
if(wParam ==5 ) //5 is control ID
{
NMHDR *ph =(NMHDR*)lParam;
if(ph->code==NM_CLICK)
MessageBox("Click");
else if(ph->code==HDN_ITEMCLICK)
MessageBox("Item Click");
else
{
CString str;
str.Format("%d",ph->code);
MessageBox(str);
}
}
return CDialog::OnNotify(wParam, lParam, pResult);
}
Now there still a very small prolem: what messages should I handle for 'Selected Item Changed' event ?? I know its easy but I couldnt find it
Regards
mohgdeisat: I am sorry, I made a mistake about WM_COMMAND.
OdeeanRDeathshead is right, I was thinking of a list box not list view.
To make up for this, here is some sample code from a win32 dialog app that uses list view control. I hope it will be of some help:
Code:
//this is from the dialog window function:
case WM_NOTIFY: //handle events:
nmhdr = (LPNMHDR)lParam;
switch (nmhdr->idFrom)
{
case IDC_LEDLIST: //list control ID.
return OnLEDListEvent(hwndDlg, (LPNMLISTVIEW)lParam);
break;
}
break;
BOOL OnLEDListEvent(HWND hwndDlg, LPNMLISTVIEW nmlv)
{
/////
// Handles list view control notification messages
switch (nmlv->hdr.code)
{
case LVN_ITEMCHANGED:
return OnLEDListItemChanged(hwndDlg, nmlv);
break;
}
return 0;
}
BOOL OnLEDListItemChanged(HWND hwndDlg, LPNMLISTVIEW nmlv)
{
if (ListView_GetSelectionMark(nmlv->hdr.hwndFrom) != nmlv->iItem) return 0;
/* do what you need here */
return 0;
}
Don't mind the fact that I used 3 different functions. This is part of a bigger program and I am trying to keep things well organized without resorting to classes.
As I understand it, LVN_ITEMCHANGE is received for different reasons so I try to handle only the one coming from selected item. LVN_ITEMACTIVATE is only sent when you double click the item so if you just want to catch selection change you need to use LVN_ITEMCHANGE.
Once again, sorry for confusing you before.
thanx pals, good job!!!
I think my problem is now solved with ur help :wink:
Mohammad
Ok guys, I said that my problem was solved, yet, another problem arises...
When the list view is in the report mode, how can I determine when a header button is clicked, and determine which one was clicked???????
thanx in advance
To identify a header column click, you need to handle the WM_NOTIFY/HDN_ITEMCLICK message. Normally this message will be received by the header's parent control (i.e. the listview) -- some frameworks may redirect the message to the header control itself. I haven't worked with MFC in 10 years so I can't really if it reflects notification messages back to the control.
If you're trying to implement column sort, do yourself a favor and check out the Windows Template Library (WTL) at sourceforge.net. It's a set of C++ template classes that provide a thin yet useful wrapper around the standard Windows UI components. One of the classes is a sortable listview control. I've been using WTL with big Windows for more than 5 years -- you couldn't pay me to go back to MFC.
hi,
I have seen the WTL library and it seems very useful and time-saver, but I have a couple of questions about it:
1. can WTL 8.0 be installed with VC++ 6.0, specifically the appwizard stuff??how?? I see only javascript files of vc7.0 and 7.1 and 8.0!!
2. is there a good documentation about those classes??
Mohammad
I don't know about WTL 8; I'm still using WTL 7.5 with VS .Net 2003 for all my Win32 development. My guess is that it wouldn't work too well, as WTL is based on ATL, which has substantially changed between VC 6 and 7.
Good references for WTL include www.codeproject.com/wtl, and the WTL group over at Yahoo groups (reflected at www.gmane.org).

[Q] app crashes whenever call is made to change the content viewthe

whenever I use
Code:
tv.setText("Game Over!"); setContentView(tv);
my program crashes (note: tv is an object of the TextView class)
Before this call is made the program is set to a default view that contains a text view, buttons, etc. But the crash only happens when I call the method to change the view. Any ideas?
You probably wouldnt wanna do setContentView on a textview, unless its the only thing you want on the screen. Are you creating the textview dynamically? (In the java code) Or is this a textview you create in the xml. If you are doing it dynamically, are you giving it LayoutParams first?
Yes its dynamic. What kind of LayoutParams do you mean?
Sent from my GT-I9000M using XDA App
If you just create a new textview...
TextView text = new TextView(context);
its just floating around not attached to anything. Just create a quick layout with a textview in it, and do
setContentView(R.layout.layout2);
or you could try
tv.setLayoutParams(new LayoutParams(LayoutParam.WRAP_CONTENT,LayoutParam.WRAP_CONTENT));
It still crashes, no matter what I do as soon as I try to do anything with the TextView tv, it crashes
setting it works: final TextView tv = (TextView) findViewById(R.id.stats);
But doing ANYTHING with tv crashes.
Examples:
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams. WRAP_CONTENT));
tv.setText("testing");
Anything I'm overlooking?
Well for starters you cant change anything about a variable that you declare as final..

Image Low Quality

Hey,
So I'm making an app that needs to display a bitmap or raw (something where X/Y pixels can be modified, so no compression like a jpg).
There's an Activity which contains only an ImageView, I get the Bitmap from the bundle given in the callback from the camera (it's put into the intent before the Activity starts), then I set it to the ImageView in onCreate of this new Activity (which is basically only an ImageView).
For some reason, when viewing this Activity, the picture is of EXTREMELY low quality. Like, tons of jaggies, like it's a thumbnail or something and is force-scaled up to the screen size. The image isn't really like this, though, when I view it in my gallery it's crystal clear. So why is the quality being dragged down to all hell when I set it in the ImageView? I don't care about the performance constraints, this isn't a production app.
I feel there's some quality control function in the ImageView or something, but I have no idea what. Can somebody tell me the "why" or the "fix" - plzzzz - I'm on a really truncated time schedule and haven't had much luck with this camera for too long .
TIA
Syndacate said:
Hey,
So I'm making an app that needs to display a bitmap or raw (something where X/Y pixels can be modified, so no compression like a jpg).
There's an Activity which contains only an ImageView, I get the Bitmap from the bundle given in the callback from the camera (it's put into the intent before the Activity starts), then I set it to the ImageView in onCreate of this new Activity (which is basically only an ImageView).
For some reason, when viewing this Activity, the picture is of EXTREMELY low quality. Like, tons of jaggies, like it's a thumbnail or something and is force-scaled up to the screen size. The image isn't really like this, though, when I view it in my gallery it's crystal clear. So why is the quality being dragged down to all hell when I set it in the ImageView? I don't care about the performance constraints, this isn't a production app.
I feel there's some quality control function in the ImageView or something, but I have no idea what. Can somebody tell me the "why" or the "fix" - plzzzz - I'm on a really truncated time schedule and haven't had much luck with this camera for too long .
TIA
Click to expand...
Click to collapse
what other info does the camera intent return, what extras?
alostpacket said:
what other info does the camera intent return, what extras?
Click to expand...
Click to collapse
How do I check?
I used somebody else's tutorial to learn that the URI is in the 'data' of the bundle.
I tried checking earlier by using its to-string, but that just gave me the container size.
Syndacate said:
How do I check?
I used somebody else's tutorial to learn that the URI is in the 'data' of the bundle.
I tried checking earlier by using its to-string, but that just gave me the container size.
Click to expand...
Click to collapse
you probably have the URI to the thumbnail
Post the tutorial you used and some code, shouldn't be too hard to figure out.
alostpacket said:
you probably have the URI to the thumbnail
Post the tutorial you used and some code, shouldn't be too hard to figure out.
Click to expand...
Click to collapse
There's like upteen thousand tutorials that I compiled to make what I have.
I have no "links" anymore.
I got the Intent from the camera in the onActivityResult function after calling the camera. I pulled the bundle from it using the getExtras() function on the intent.
I then passed that intent to the new Intent I made to create my second Activity. I passed it via the putExtras function on the new intent.
In essence, I did;
Code:
Intent in = new Intent();
in.putExtras(incoming_intent_from_camera.getExtras());
And then called my second Activity.
In the onCreate() function of my second Activity, I pull the bitmap data using:
Code:
Bitmap bmp = (Bitmap)getIntent().getExtras().get("data");
There are two things in this Bundle, data (a Bitmap (android.graphics.Bitmap)) and a bitmap-data, which is a boolean.
EDIT:
Yes, it is definitely the URI to the thumbnail, I need the large image URI.
I have a feeling the problem is that it needs the EXTRA_OPTION string, the only issue is, I don't want to save this any place in particular. I'll let the camera save it to the default location on my SDCard. I just want the URI to that full size or something usable.
I can't do:
Code:
intent.putExtra(MediaStore.EXTRA_OPTION, <URI>);
Because I don't have nor want an additional URI to store it... I got to get EXTRA_OPTION to the camera somehow..
Okay, so here's the deal, that apparently nobody was able to help me with ():
- Like alostpacket said, the "data" key in the bundle returned from the camera activity (in the callback) contains the URI to the thumbnail - that's useless unless I'm making an icon or some other small/tiny/low res picture.
I was correct in the fact that it had something to do with putting the EXTRA_OPTION into the extras that I passed off to the camera intent.
This DID come at a price, though. You have to make a temporary place to store the image (you know, because the regular one in the gallery just isn't good enough of or something). And by temporary I kind of mean permanent, it gets overwritten every time (assuming you use the same path), but won't get removed. I am unable to understand this functionality. If somebody could explain it that would be great.
So all in all my intent to the camera looks like this:
Code:
image_path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmp_image.jpg";
File img = new File (image_path);
Uri uri = Uri.fromFile(img);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(intent, PICTURE_REQUEST);
Where image_path is a private class String and PICTURE_REQUEST is a final String (also class level scope) - which can represent any non-0 number, but is unique to the request (think of it as a request ID).
Then, in the callback function, after checking to make sure the request code is PICTURE_REQUEST, and the resultCode was OK:
Code:
Bitmap bmp = BitmapFactory.decodeFile(image_path);
img_view.setImageBitmap(bmp);
img_view.invalidate();
Where image_path is (a String) wherever the image specified as an extra to the camera activity, img_view is an ImageView display element. The invalidate method will redraw the ImageView.
I hope that helps somebody else stuck in the same position I am.
I'm going to leave this question as "unresolved" because there's one thing I still can't figure out. The "EXTRA_OUTPUT" extra passed to the intent seems like a work-around. All that does is define an alternate path to write the file to, then the callback (or whatever) grabs it from there. It's a hack and a half. There has to be a legit way to grab the full quality image taken with the camera. Whether that's accessing the gallery intent or not I'm not sure, but this is definitely a work around. I hope somebody can provide the answer to that, because a lot of tutorials mention the EXTRA_OUTPUT method, and given what it does, I don't believe that is correct.

[Q] Help with Gallery App

I have found a Gallery App on GitHub (https://github.com/sevenler/Android_Gallery2D_Custom) that I have integrated into my own app.
Currently the gallery displays all images from my device. What I would like to have is that it ONLY display the images starting at the folder on my sdcard that I specify such as..
private static String targetPath = Environment.getExternalStorageDirectory().toString() + "/DCIM/_private/.nomedia";
I tried several different modifications but I am really struggling.
I was hoping someone could take a look at the source code for the Gallery App on GitHub and tell me how to change it so it does not scan my entire device.
Thanks in advance!!
-Steve
StEVO_M said:
I have found a Gallery App on GitHub (https://github.com/sevenler/Android_Gallery2D_Custom) that I have integrated into my own app.
Currently the gallery displays all images from my device. What I would like to have is that it ONLY display the images starting at the folder on my sdcard that I specify such as..
private static String targetPath = Environment.getExternalStorageDirectory().toString() + "/DCIM/_private/.nomedia";
I tried several different modifications but I am really struggling.
I was hoping someone could take a look at the source code for the Gallery App on GitHub and tell me how to change it so it does not scan my entire device.
Thanks in advance!!
-Steve
Click to expand...
Click to collapse
I had a look at the source and from my understanding the important class here is that DataManager class here. Especially the getTopSetPath() with the static final Strings and maybe the mapMediaItems() methods seem to be where you need to look at. You might have to play around a bit, but this is where I would start.
SimplicityApks said:
I had a look at the source and from my understanding the important class here is that DataManager class here. Especially the getTopSetPath() with the static final Strings and maybe the mapMediaItems() methods seem to be where you need to look at. You might have to play around a bit, but this is where I would start.
Click to expand...
Click to collapse
I have tried adding/changing the following
Added...
//Setting Folder Path
public static final String targetPath = Environment.getExternalStorageDirectory().toString() + "/DCIM/_private/.nomedia";
Changed...
// This is the path for the media set seen by the user at top level.
private static final String TOP_SET_PATH = targetPath;
private static final String TOP_IMAGE_SET_PATH = "/combo/{/mtp,/local/image,/picasa/image}";
private static final String TOP_VIDEO_SET_PATH = "/combo/{/local/video,/picasa/video}";
private static final String TOP_LOCAL_SET_PATH = "/local/all";
private static final String TOP_LOCAL_IMAGE_SET_PATH = "/local/image";
private static final String TOP_LOCAL_VIDEO_SET_PATH = "/local/video";
I even tried setting all of the _PATH s to my targetPath
And I get a NullPointerException
12-13 11:07:47.881: E/AndroidRuntime(23029): Caused by: java.lang.NullPointerException
12-13 11:07:47.881: E/AndroidRuntime(23029): at com.myprivgallery.common.Utils.checkNotNull(Utils.java:48)
Which leads me to this in Utils.java
line 46 // Throws NullPointerException if the input is null.
line 47 public static <T> T checkNotNull(T object) {
line 48 if (object == null) throw new NullPointerException();
line 49 return object;
line 50 }
So if I am reading correctly, it is saying the path is empty. But I know that path works in other apps and it is not empty.
StEVO_M said:
I have tried adding/changing the following
Added...
//Setting Folder Path
public static final String targetPath = Environment.getExternalStorageDirectory().toString() + "/DCIM/_private/.nomedia";
Changed...
// This is the path for the media set seen by the user at top level.
private static final String TOP_SET_PATH = targetPath;
private static final String TOP_IMAGE_SET_PATH = "/combo/{/mtp,/local/image,/picasa/image}";
private static final String TOP_VIDEO_SET_PATH = "/combo/{/local/video,/picasa/video}";
private static final String TOP_LOCAL_SET_PATH = "/local/all";
private static final String TOP_LOCAL_IMAGE_SET_PATH = "/local/image";
private static final String TOP_LOCAL_VIDEO_SET_PATH = "/local/video";
I even tried setting all of the _PATH s to my targetPath
And I get a NullPointerException
12-13 11:07:47.881: E/AndroidRuntime(23029): Caused by: java.lang.NullPointerException
12-13 11:07:47.881: E/AndroidRuntime(23029): at com.myprivgallery.common.Utils.checkNotNull(Utils.java:48)
Which leads me to this in Utils.java
line 46 // Throws NullPointerException if the input is null.
line 47 public static <T> T checkNotNull(T object) {
line 48 if (object == null) throw new NullPointerException();
line 49 return object;
line 50 }
So if I am reading correctly, it is saying the path is empty. But I know that path works in other apps and it is not empty.
Click to expand...
Click to collapse
I don't think you can call an Environment method when static class variables are Initialised make sure that your String is the correct path with Logs, I would probably make that an instance variable instead...
SimplicityApks said:
I don't think you can call an Environment method when static class variables are Initialised make sure that your String is the correct path with Logs, I would probably make that an instance variable instead...
Click to expand...
Click to collapse
It may kinda look like I know what I'm doing, but looks are deceiving.
I really have no clue what I am doing. I consider myself a hack. I can some what look at code and then make it do what I want, but to actually program something new... I will see if I can't figure that out. But I really do appreciate your help.
StEVO_M said:
It may kinda look like I know what I'm doing, but looks are deceiving.
I really have no clue what I am doing. I consider myself a hack. I can some what look at code and then make it do what I want, but to actually program something new... I will see if I can't figure that out. But I really do appreciate your help.
Click to expand...
Click to collapse
Well then you should probably get started on a simpler app you've built yourself rather than trying to understand this very complex Gallery app (which in my view is poorly commented and documented)...
I had a closer look at the source and it seems that we are on the right track because the _PATH s are used in the getTopSetPath method of the DataManager, and a search reveals that it is called by various activities and pickers. If you're using one of those in your app we should be right.
Now let's get back to the basics, when the app is launched, the default launcher activity is Gallery.java. During it's creation, either startDefaultPage, startGetContent or startViewAction is called, but all of them have the following call:
Code:
data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager().getTopSetPath(DataManager.INCLUDE_ALL)); // or some other variable
So this is the path where the images are loaded. Honestly, I have no idea what the
Code:
"/combo/{/mtp,/local/all,/picasa/all}"
is doing in the path variable, it has to do something with the Combo classes in the data folder, since the app is loading images from different dirs. You can now call your Environment call there and somehow pass back Strings instead of Paths, but it would be nicer if we could somehow figure out the these Paths are used here. An important class is the LocalPhotoSource.java. That is also where getImage from the DataManager is called. You could have a look at that class as well. Which path do you want the gallery to scan actually? The best solution would be to further experiment with the _PATH String, without calling Environment as well as debugging the whole app from the start, so you can get an idea of how everything is working.
SimplicityApks said:
Well then you should probably get started on a simpler app you've built yourself rather than trying to understand this very complex Gallery app (which in my view is poorly commented and documented)...
I had a closer look at the source and it seems that we are on the right track because the _PATH s are used in the getTopSetPath method of the DataManager, and a search reveals that it is called by various activities and pickers. If you're using one of those in your app we should be right.
Now let's get back to the basics, when the app is launched, the default launcher activity is Gallery.java. During it's creation, either startDefaultPage, startGetContent or startViewAction is called, but all of them have the following call:
Code:
data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager().getTopSetPath(DataManager.INCLUDE_ALL)); // or some other variable
So this is the path where the images are loaded. Honestly, I have no idea what the
Code:
"/combo/{/mtp,/local/all,/picasa/all}"
is doing in the path variable, it has to do something with the Combo classes in the data folder, since the app is loading images from different dirs. You can now call your Environment call there and somehow pass back Strings instead of Paths, but it would be nicer if we could somehow figure out the these Paths are used here. An important class is the LocalPhotoSource.java. That is also where getImage from the DataManager is called. You could have a look at that class as well. Which path do you want the gallery to scan actually? The best solution would be to further experiment with the _PATH String, without calling Environment as well as debugging the whole app from the start, so you can get an idea of how everything is working.
Click to expand...
Click to collapse
I tried Changing the following in LocalAlbumSet.java
public class LocalAlbumSet extends MediaSet {
public static final Path PATH_ALL = Path.fromString("/DCIM/_private/.nomedia/all");
public static final Path PATH_IMAGE = Path.fromString("/DCIM/_private/.nomedia/image");
public static final Path PATH_VIDEO = Path.fromString("/DCIM/_private/.nomedia/video");
and Changing all of the TOP_..._Path s to
// This is the path for the media set seen by the user at top level.
private static final String TOP_SET_PATH = "/local/all";
private static final String TOP_IMAGE_SET_PATH = "/local/image";
private static final String TOP_VIDEO_SET_PATH = "/local/video";
private static final String TOP_LOCAL_SET_PATH = "/local/all";
private static final String TOP_LOCAL_IMAGE_SET_PATH = "/local/image";
private static final String TOP_LOCAL_VIDEO_SET_PATH = "/local/video";
I now see Random Images from /DCIM/_private/.nomedia but not all of them, which is really confusing. But at least it's a start.
StEVO_M said:
I have found a Gallery App on GitHub (https://github.com/sevenler/Android_Gallery2D_Custom) that I have integrated into my own app.
Currently the gallery displays all images from my device. What I would like to have is that it ONLY display the images starting at the folder on my sdcard that I specify such as..
private static String targetPath = Environment.getExternalStorageDirectory().toString() + "/DCIM/_private/.nomedia";
I tried several different modifications but I am really struggling.
I was hoping someone could take a look at the source code for the Gallery App on GitHub and tell me how to change it so it does not scan my entire device.
Thanks in advance!!
-Steve
Click to expand...
Click to collapse
Android gallery will not scan any folder having a .nomedia file in it.
EatHeat said:
Android gallery will not scan any folder having a .nomedia file in it.
Click to expand...
Click to collapse
So I am guessing there is no way to Force your own instance to scan it????
StEVO_M said:
So I am guessing there is no way to Force your own instance to scan it????
Click to expand...
Click to collapse
Delete the .nomedia file.
Lol. Not an option if I want to hide my pic.
Sent from my HTCONE using Tapatalk
Not sure what you are trying to achieve, if you want to scan it then why would you want to hide it?
If you want to add an option to allow it to scan or not, you could backup the .nomedia to another directory and delete it for the time being.
Just an idea, can't say for sure. Didn't try it ever.
I have created an app to hide pictures. Currently I have a very basic gallery. I was trying integrate this gallery because it has a lot more option such as editing and adding filters and such.
Sent from my HTCONE using Tapatalk
StEVO_M said:
I have created an app to hide pictures. Currently I have a very basic gallery. I was trying integrate this gallery because it has a lot more option such as editing and adding filters and such.
Click to expand...
Click to collapse
Well why do you need to? Make your app fulfill only one purpose, so let it hide the pictures (I guess by moving a .nomedia file into the folder right?) and then just create a shortcut in your app to the gallery app so the user can still use their preferred one... Makes more sense to me and is way less work.
StEVO_M said:
I have created an app to hide pictures. Currently I have a very basic gallery. I was trying integrate this gallery because it has a lot more option such as editing and adding filters and such.
Sent from my HTCONE using Tapatalk
Click to expand...
Click to collapse
A far more simple and logical way would be to create a hidden folder on the SD card with a .nomedia file in it. Images/videos that are to be hidden can be moved to that location. This would keep it hidden from the gallery and can only be accessed through your private gallery.
For unhiding media, just move them back to their original folders.
Let me try to explain further... As I said, I have created an app already that does the Basic things.
My Application looks like a standard App, a "To Do List", but if you press and hold an Icon on the main screen it prompts you for a Password (These passwords are setup on first use).
Now... Depending on which password you enter, it will either take you to the hidden Gallery OR if you enter a different password it will take you to a Hidden To Do List. This is so anyone that may stumble upon your app, you can show them that it's has a hidden area of the app. This way they have no clue you really have a Hidden Gallery.
If you enter the Hidden Gallery password then it would of course, take you to the hidden gallery.
The Current Features are...
Import from Main Gallery
Pinch to Zoom
Swipe
Share
Restore back to Main Gallery
Delete
Quick Escape ------ "Quick Escape" can be activate 2 ways. If you shake the phone while in the Hidden Gallery, the image will change to an image of your choosing or the default one that is set during install. OR..... A less obvious "Quick Escape" ... While in the Hidden Gallery, press the volume up or down and the image will switch. Either way, once it is in that mode, you can not press back. the only way out it to press the home button. This is designed so if someone grabs the phone out of your hand they will only see they Quick Escape" image and pressing back will not take them back to the gallery.
My app also appears in the standard Share menu, so if you are in your Main Gallery and want to hide a picture, you can share it to my app and it will then hide the picture.
I want to add More features to my Gallery, such as Filters, Editing (crop, rotate...), Frames... All the same things that you can do in the Main Gallery. The only thing I really don't want or need is a Camera function. I can't see someone taking the time to open my app and then get to the Hidden Gallery and then taking a picture, just so they can hide an image. Most would just take the picture as they always would and then "Share" it to my app.
I hope this explains Why I want to use the other Gallery rather than reinventing the wheel that already has all of these features built in. If I can not get that to work, maybe I can just pull the Features out and use those.
Anyone who wants to actually See the app in action, PM me and I will send you a DropBox link to install. FYI, It requires 4.0 or higher.

[Q] Beginner: Issues with canvas bitmaps, buttons, and layouts

[Q] Beginner: Issues with canvas bitmaps, buttons, and layouts
Hi, I'm hoping people might help me with this more open-ended question. I'm fairly new to programming with little scripting experience.
My problem is that I'm cobbling code together from various separate examples, but trying to implement them into my tests, they don't seem to work together.
Let me show you what my goals are for this experiment:
1) Create Button
2) Generate Images with Button click
3) Drag Images around
So far, I've been able to do create images with drawing bitmaps using canvas and create a working button with the easy drag and drop.
My specific problem is that I can't use the Design tool to create buttons if I use the canvas method of drawing bitmaps because setContentView() needs to be on the canvas.
Here's my onCreate():
Code:
GenerateItem ourView;
Button genButton;
LinearLayout myLinearLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ourView = new GenerateItem(this);
setContentView(ourView);
myLinearLayout = (LinearLayout)findViewById(R.id.linearLayout1);
genButton = new Button(this);
genButton.setText("Generate");
myLinearLayout.addView(genButton);
}
And related XML code from my AndroidManifest:
Code:
<LinearLayout xmlns:android="somelink"
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</LinearLayout>
Now I have two questions:
1) Am I going about this problem the correct way using a mix of Design layout tools and code created images (canvas bitmaps)?
2) Can I use canvas bitmaps with an onTouchListener as a button?
Whoaness said:
2) Can I use canvas bitmaps with an onTouchListener as a button?
Click to expand...
Click to collapse
You should use an ImageView instead. Canvas aren't Views, so they aren't managed by the Android System when an event occurs. Canvas are used, for example, to draw anything in a low-level-way (custom views, for example).
I didn't understand the first question..
Sent from my Vodafone 875
Andre1299 said:
You should use an ImageView instead. Canvas aren't Views, so they aren't managed by the Android System when an event occurs. Canvas are used, for example, to draw anything in a low-level-way (custom views, for example).
I didn't understand the first question..
Sent from my Vodafone 875
Click to expand...
Click to collapse
You might have answered my first question. I'm not sure.
I was asking whether I should stick with canvas methods and, from my limited scripting knowledge, draw a hitbox for the onTouch method to detect so I can redraw the object to the fingers position.
I can easily drag imageviews/imagebuttons around. I guess I have to figure out how to create Imageviews, though I think I seen a way to cast bitmaps into an imageview, but it never worked out for me.
Whoaness said:
You might have answered my first question. I'm not sure.
I was asking whether I should stick with canvas methods and, from my limited scripting knowledge, draw a hitbox for the onTouch method to detect so I can redraw the object to the fingers position.
I can easily drag imageviews/imagebuttons around. I guess I have to figure out how to create Imageviews, though I think I seen a way to cast bitmaps into an imageview, but it never worked out for me.
Click to expand...
Click to collapse
Uhm... so, let me know wheter I understood.
In your project you have a button that renders an image (a bitmap) wich is drawn with a canvas. But you want that this image is draggable.
Am I right?
Andre1299 said:
Uhm... so, let me know wheter I understood.
In your project you have a button that renders an image (a bitmap) wich is drawn with a canvas. But you want that this image is draggable.
Am I right?
Click to expand...
Click to collapse
Yes, draggable image button. Although I'm not sure if it needs to be a button, but I thought button properties would be appropriate for touch and dragging.
Sorry for the late reply. I was on a hiatus.

Categories

Resources