Skip to content

Instantly share code, notes, and snippets.

@riccardopirani
Created June 6, 2018 10:30
Show Gist options
  • Save riccardopirani/4b33e1862cb8db9f788774c6034b3884 to your computer and use it in GitHub Desktop.
Save riccardopirani/4b33e1862cb8db9f788774c6034b3884 to your computer and use it in GitHub Desktop.
Cast Image64 to ImageView Android
//IMG: JVBERi0xLjMKJf////8KMSAwIG9iago8PCAvQ3JlYXRvciA8ZmVmZjAwNTAwMDcyMDA2MTAwNzcwMDZlPgo....
//Java Code:
public class RapportiniActivity extends Fragment {
private View view;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = (View) inflater.inflate(R.layout.activity_rapportini, container, false);
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Do all things which you want to implement //enter code here
final Button btnGeneraRapportino = (Button)view.findViewById(R.id.buttongenera_rapportino);
final ImageView img= (ImageView)view.findViewById(R.id.ImageView_Rapportino);
//Configuro la funzione Listener sul login button
btnGeneraRapportino.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Rapportino r=new Rapportino();
String ImageBase64=r.GeneraRapportinoPrivato("prova");
byte[] decodedString = Base64.decode(ImageBase64, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
img.setImageBitmap(decodedByte);
}
});
}
}
//XML CODE:
<ImageView
android:id="@+id/ImageView_Rapportino"
android:layout_width="200dp"
android:layout_height="300dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="100dp"
android:src="#222"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment