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

51
LINES

< > BotCompany Repo | #1001080 // Android: Trying to emulate BorderLayout... (making a console)

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

Libraryless. Click here for Pure Java version (77L/1K/4K).

1  
!752
2  
3  
import android.app.*;
4  
import android.widget.*;
5  
import android.view.*;
6  
import android.view.KeyEvent;
7  
import android.view.inputmethod.*;
8  
import android.text.*;
9  
10  
11  
  static Activity androidContext;
12  
  
13  
  p {
14  
    androidContext.runOnUiThread(runnable {
15  
      Activity context = androidContext;
16  
      
17  
      LinearLayout ll = new LinearLayout(context);
18  
      ll.setOrientation(ll.VERTICAL);
19  
      
20  
      final TextView tv = new TextView(context);
21  
      tv.setText("Hello\nworld");
22  
      tv.setBackgroundColor(0xFFFFFFCC);
23  
      
24  
      ScrollView sv = new ScrollView(context);
25  
      sv.setBackgroundColor(0xFFFFFFCC);
26  
      sv.addView(tv);
27  
      //sv.setGravity(Gravity.FILL_VERTICAL);
28  
      sv.setLayoutParams(new LinearLayout.LayoutParams(
29  
                             LinearLayout.LayoutParams.MATCH_PARENT,
30  
                             LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
31  
      
32  
      ll.addView(sv);
33  
        
34  
      final EditText et = new EditText(context);
35  
      et.setInputType(InputType.TYPE_CLASS_TEXT); // Hopefully turns off multiline
36  
      
37  
      et.setOnEditorActionListener(new TextView.OnEditorActionListener() {
38  
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
39  
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
40  
                tv.setText("Yo: " + et.getText());
41  
            }
42  
            return false;
43  
        }
44  
      });
45  
    
46  
    
47  
      ll.addView(et);
48  
      
49  
      context.setContentView(ll);
50  
    });
51  
  }

Author comment

Began life as a copy of #1001079

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001080
Snippet name: Android: Trying to emulate BorderLayout... (making a console)
Eternal ID of this version: #1001080/1
Text MD5: a1b2a29c7776abbc19e55ab5fdbb0c69
Transpilation MD5: c521b1208ee703386f6681c08a8467a0
Author: stefan
Category: javax
Type: JavaX source code (Android)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-31 02:34:25
Source code size: 1596 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 731 / 655
Referenced in: [show references]