Created
June 6, 2018 10:30
-
-
Save riccardopirani/4b33e1862cb8db9f788774c6034b3884 to your computer and use it in GitHub Desktop.
Cast Image64 to ImageView Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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