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

52
LINES

< > BotCompany Repo | #1000405 // Android on-screen log test (log, class Lg)

JavaX source code (Android) - run with: the app

1  
import android.widget.*;
2  
import android.view.*;
3  
import android.content.Context;
4  
import android.app.Activity;
5  
import java.util.Timer;
6  
import java.util.TimerTask;
7  
8  
public class main {
9  
  static class Lg {
10  
    ScrollView sv;
11  
    TextView tv;
12  
    StringBuilder buf = new StringBuilder();
13  
    
14  
    Lg(Activity context) {
15  
      sv = new ScrollView(context);
16  
      tv = new TextView(context);
17  
      tv.setText(buf.toString());
18  
      sv.addView(tv);
19  
    }
20  
    
21  
    View getView() {
22  
      return sv;
23  
    }
24  
    
25  
    void print(String s) {
26  
      buf.append(s);
27  
      tv.setText(buf.toString());
28  
    }
29  
    
30  
    void println(String s) {
31  
      print(s + "\n");
32  
    }
33  
  }
34  
  
35  
  static Lg log;
36  
  
37  
  public static View main(final Activity context) {
38  
    log = new Lg(context);
39  
    Timer myTimer = new Timer();
40  
    myTimer.schedule(new TimerTask() {          
41  
      public void run() {
42  
        context.runOnUiThread(new Runnable() {
43  
          public void run() {
44  
            log.println("More text");
45  
          }
46  
        });
47  
      }
48  
    }, 0, 1000);
49  
    
50  
    return log.getView();
51  
  }
52  
}

Author comment

Began life as a copy of #1000404

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000405
Snippet name: Android on-screen log test (log, class Lg)
Eternal ID of this version: #1000405/1
Text MD5: db27aaf6ca8f253bf729521aef61c2a1
Author: stefan
Category: javax android
Type: JavaX source code (Android)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-03 03:04:17
Source code size: 1119 bytes / 52 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 576 / 491
Referenced in: [show references]