Good day,
I am trying to add a textview preview to my app. For example, i created a news app with card view and I want to have a few lines on the first screen and then it expands the full story in a new activity onclick.
I have already set up the new activity part but I just need the preview on the first screen
You should have all the News data available on your first Activity - NewsActivity.
In that case you just
Limit number of lines of preview TextView with attribute android:maxLines="3"
Then on click on TextView you would open another activity with an Intent and inside the Intent pass whole News object that corresponds to data displayed in preview TextView. Remember that News object should be implement Serializable or Parcelable interfaces to be passed with intent.
Retrieve data from an Intent and display it in the second Activity - NewsDetailsActivity
Related
I have a requirement in android application to show 5 buttons each of them will open the camera intent to allow the user to take a picture. every image is related to a certain information thus each of the images will have a description in the data base and a special id. for example, the first button is to take an image of a car. therefore all images that taken for cars will have id = 1 and a description like "Image of the car .." and so on.
also when the user take the picture I will replace the button with another button to view the image that just has been taken.
Now what i tried to do when the user clicks on the first button I put an extra to the intent with id = 1 and in onActivityResult i'll check if the extra is equal to 1 I will store the image and its id in an hash map. But unfortunately I can't use extras with implicit intent calls.
Any idea or suggestion?
use different request_code for intent from all button and based on request_code you can perform action accordingly in onActivityResult .
I have a Media Player UI in a Fragment in Main Activity which plays all songs from the emulator. Below this fragment I have List of Playlists. I can click on any of the playlists name and second activity opens with names of songs in that playlist. What I want is that after navigating to new Activity I should still be able to see the same fragment from Main Activity playing the song with Title and Artist name. Also I have to maintain the current state of player like seekbar progress irrespective doing back and forth between multiple activities. Can this be achieved without having to create a new Fragment (and thus have fragment to fragment data sharing) in second Activity and instead load the Fragment from Main Activity as it is? If new Fragment needs to be created in Second Activity how should I pass the song detail like Album art, Title, Artist etc. from first fragment to second fragment?
I have a ListView that is like an inbox. The information comes from a user,so the ListView displays text and a userPicture.To display userPictures, I display the userPicture if exists or a imageView of a letter of the first name.
when I receive data from WS I launch an asynctask that compare userPicture ids with DB to ask the WS for ones I don't have or one's that have changed.
After the asyncTask finishes I save pictures locally and notify listView that the data set has changed, in order to look for the new pictures.
my problem comes when there is only 1 user on the listview and the picture wasn't found but was downloaded from WS. after calling notifyDataSetChanged, also calling refreshDrawableState and invalidateViews,that acording to documentation "Causes all the views to be rebuilt and redrawn". the image is not changed and imageView still shows the letter ImageView,
neither scrolling through the listView its updated. (I guess is part of the Viewholder that recycle the views that is meant for performance and a good practive acording to ).
on the getView of the adapter I have a the Following statement to processThe Picture
if(mIDataPersistence.userHasPicture(userId)
ViewHolder.userImg.setImageBitmap(mIDataPersistence.getUserPicture(userId));
else
ViewHolder.userImg.setImageBitmap(BitmapUtils.createBitMap(userName);
note: mIDataPersistence is persistence data interface to access all the data locally stored that I'm using here. and BitmapUtils.createBitMap() makes a bitmap from the first letter of the user.
can anyone help me or point me on a way to make listView update images in this particular case.
I have little problem with my Android app.
First i take a photo by a camera and save it as Bitmap. Next thing i want to do is display this image in new fragment as ImageView. I don't know how to send this photo from activity to fragment.
Could you help how to do that?
You are taking the photo in the activity, so the fastest way to figure out this problem is saving your image in cache and reading directly form its path in the fragment code.
Did you try this?
I see two solutions:
Since you are taking a picture in one Activity and want to get it in a Fragment (which has an Activity), you could put the bitmap path on bundle on the Take Picture activity (bundle.putString("bitmapPath", bitmap.getPath())) and read this bundle on the Show Picture Activity Fragment (getActivity().getExtras().get("bitmapPath")).
You could use a public static variable to keep bitmap path after you saving it.
In my application i am using tabhost. And to control different activities i am using activity group. I have Activity A from which i am going to activity B. Activity B contains Edit Text, Spinner, Button etc. Now when i scroll the Activity B and press the device Back Button than it does not go to the previous Activity. It goes out of application.
Kindly suggest the answer.
This is the way the Activity lifecycle works for Activity Group. Try using fragments instead of activity group with your tabhost to get your movements. Also, please edit your question title to more accurately reflect the actual question.