Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1000419 // ImageView test (Android, in ScrollView)

JavaX source code (Android) [tags: use-pretranspiled] - run with: the app

Libraryless. Click here for Pure Java version (52L/1K/3K).

!636

import android.app.Activity;
import android.widget.*;
import android.graphics.*;

main {
  static Activity androidContext;
  
  psvm {
    System.out.println("Hello world!");
    System.out.println("androidContext = " + androidContext);
    ImageView iv = new ImageView(androidContext);
    
    int w=256, h=256;
    int[] pixels = new int[w*h];
    for (int i=0; i < w*h; i++)
      pixels[i] = i;

    Bitmap bitmap = Bitmap.createBitmap(pixels, w, h, Bitmap.Config.RGB_565);
    iv.setImageBitmap(bitmap);

    final ScrollView sv = new ScrollView(androidContext);
    sv.addView(iv);

    androidContext.runOnUiThread(new Runnable() {
      public void run() {
        androidContext.setContentView(sv);
      }
    });
    print "yo"
  }
}

Author comment

Began life as a copy of #1000417

download  show line numbers  debug dex  old transpilations   

Travelled to 19 computer(s): adtiomwmedle, aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, exkalrxbqyxc, fumpprspadck, gwrvuhgaqvyk, hlxwmvgyfkur, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, ufhdzwgrioxs, vouqrxazstgt

No comments. add comment

Snippet ID: #1000419
Snippet name: ImageView test (Android, in ScrollView)
Eternal ID of this version: #1000419/1
Text MD5: 1cd8fc42a8f8b42188ebb2e95d364224
Transpilation MD5: cddec7e5a2b7fa9a9bdb8212cae5fff1
Author: stefan
Category: javax android
Type: JavaX source code (Android)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-06 18:59:47
Source code size: 783 bytes / 33 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 588 / 563
Referenced in: #1000423 - Example: Update widget with text (Android)
#1000684 - WebView test 2
#1001281 - androidShowFullScreenImage
#3000382 - Answer for ferdie (>> t = 1, f = 0)