I have Added the image in drawable folder and then I displayed it on layout file and also added a button and after for it i have added on click method, now I want to share images to whatsapps and fb so how can I send it... Please help me....
It's very difficult to understand what you want, because of the missing code. But I will try to help you.
I found this solution:
public void shareImage() {
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
final File photoFile = new File(getFilesDir(), "image.jpg");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(photoFile));
startActivity(Intent.createChooser(shareIntent, "Share image using"));
}
Just add shareImage() to the OnClickListener of your ImageView.
If you want more details check this, where I got the code from.
If you don't want to send an image from your gallery, then replace photoFile with the file wich you want to send.
Related
I got a school project where i need to make a cooking app, I struggle with programmaticaly importing an image to get a preview of the dish in my class.
The images are located in the drawable-v24 folder but i can't figure out ou to get the right path to it.
I want it to be a Drawable to create an image view in my layout.
package com.example.projet_info0306;
import android.graphics.drawable.Drawable;
public class Recette {
private String nom;
private Etape[] steps;
private Drawable Demo;
public Recette(String n,Etape[] e,String PathImg,) {
nom=n;
steps=e;
Demo= Drawable.createFromPath("#drawable/"+PathImg+".png");
}
}
If you want to show the Image in your App, just go to your activity_main.xml, add an ImageView to the layout and give it an ID.
You can now either link up the image statically in the XML by unsing the android:src tag or you can do it programatically by using:
Imageview imageview;
imageview = findViewByID(R.id.[yourID]);
imageview.setDrawable(R.drawable.[yourDrawable]);
NOTE: The code snippet you showed is in a normal Class not in an Activity. If you want to add one just go to your projects folder and right click on App. Android Studio will then lets you create an Activity. Or if your are not that far in the process, just create a new project and add an Activty from the beginning.
Good day!
I have extended a graph to change the screen title of an existing page.
public class NonStockItemMaintExt : PXGraphExtension<NonStockItemMaint>
{
public override void Initialize()
{
base.Initialize();
PXSiteMap.CurrentNode.Title = "My Custom Page Title";
}
}
Unfortunately, the method seems not to be working.
I also tried creating a new page for that existing graph, so that I will have the control to name the page, but as i clicked the newly created link, I am being redirected to the original page of the graph, and so the page title is still the same.
Is there any ways for me to properly rename my page?
Any advice is appreciated. Thank you.
Fixed the problem through inheritance. I also checked the aspx.cs file of the page to make sure that everything is running correctly. Thanks for all the help.
I'm new in Android programming and I need a help!!!
I hava button on a middle on screen and I want to open an image when button is clicked. Image
I believe you would need to go to another activity assuming that your image viewer is on another activity.
Intent intent = new Intent(Main.this, Image.class);
startActivity(intent);
With main being the activity your on and image being the one with the image viewer.
Hi everyone I am using eclipse to develop an android app. I have three layouts, namely a main layout and two other layouts linked to the main layout. I have created .xml and .java files for all the pages. My application runs and I can move between my main layout and one of the layouts but when I try to access the other layout the screen just blinks and nothing else happens. I am using bluestacks to test the app. below is the code for the button that is supposed to execute and move between the layouts. Show_Meds.class is the problematic one. What am I doing wrong?
`Button butEnter = (Button)findViewById(R.id.btnEnter);
butEnter.setOnClickListener(new OnClickListener(){
public void onClick(View v){
if ( rEnterMed.isChecked()){
startActivity(new Intent(MainActivity.this, Enter_Meds.class));
}
else if (rShowMed.isChecked()){
startActivity(new Intent (MainActivity.this, Show_Meds.class));
}
}//end of onClick
});`
I do not have an answer for you yet, But please verify these points to find out whats going wrong.
Also, if you are unable to produce favourable results, please post the codes for all your layout.xml files, your manifest files and your Activity.java files.
1- Make sure you have registered your Activities Enter_Meds and Show_Meds to your manifest files.
2- Try replacing the layouts xml file of MainActivity to Enter_Meds and Show_Meds one by one in setContentView. This way, you'll know if the xml view are actually working OK.
3- Inside onClick method, print out the value of v.getId() to verify if the view has been clicked correctly.
Ok so I read about loading an embedded rtf into a rich text box and I am trying to do it when the form loads. The form is not the main form, it is a second form that loads when a control is clicked. This is what I have on the form when it loads:
private void Credits_Load(object sender, EventArgs e)
{
Assembly creditAssm = Assembly.GetExecutingAssembly();
using (Stream creditStream =
creditAssm.GetManifestResourceStream("YDisplayView.credits.rtf"))
{
creditsRichTextBox.LoadFile(creditStream, RichTextBoxStreamType.RichText);
}
}
In the solution explorer the rtf file shows as a resource and the build action is set to embedded resource.
when I click the button to load the form, it shows as expected, but nothing happens. The contents of the rtf doesn't seem to show :/
I can only assume I am doing it wrong :(
Any help for this newbie would be appreciated.
I figured it out:
creditAssm.GetManifestResourceStream("YDisplayView.credits.rtf"))
needed to be:
creditAssm.GetManifestResourceStream("YDisplayView.Resources.credits.rtf"))
Edit: For some reason this time around I can't get the above code to work but I found another one that did so hopefully either/or will be of some help to new coders out there :)
string rtf = yourAppName.Properties.Resources.yourEmbeddedRTFName;
yourRichTextBox.Rtf = rtf;
I wanted to create an rtf help file named Help.rtf and have it stored as a resource and so it could be loaded when a Help form was loaded without having a Help.rtf hanging around the application folders.
I found I needed to add the rtf file to the resources through the menu's Project-> 'Your name space' Properties... then navigate to Resources tab, then Add Item etc etc... before the intellisense would offer the rtf file in it's drop-down list when I typed 'My.Resource.' Now, the list of resources including the Help file I added shows up (without extension, which is normal).
In short, once this was done, then the following worked:
RichTextBox1.rtf = My.Resources.Help
Apparently it wasn't enough just to Drag&Drop, Copy or even add the file using the 'Solution Explorer'!
Spent 3 days on this problem so I hope someone finds it usefull.