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).

!752

import android.app.*;
import android.widget.*;
import android.view.*;
import android.view.KeyEvent;
import android.view.inputmethod.*;
import android.text.*;


  static Activity androidContext;
  
  p {
    androidContext.runOnUiThread(runnable {
      Activity context = androidContext;
      
      LinearLayout ll = new LinearLayout(context);
      ll.setOrientation(ll.VERTICAL);
      
      final TextView tv = new TextView(context);
      tv.setText("Hello\nworld");
      tv.setBackgroundColor(0xFFFFFFCC);
      
      ScrollView sv = new ScrollView(context);
      sv.setBackgroundColor(0xFFFFFFCC);
      sv.addView(tv);
      //sv.setGravity(Gravity.FILL_VERTICAL);
      sv.setLayoutParams(new LinearLayout.LayoutParams(
                             LinearLayout.LayoutParams.MATCH_PARENT,
                             LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
      
      ll.addView(sv);
        
      final EditText et = new EditText(context);
      et.setInputType(InputType.TYPE_CLASS_TEXT); // Hopefully turns off multiline
      
      et.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
                tv.setText("Yo: " + et.getText());
            }
            return false;
        }
      });
    
    
      ll.addView(et);
      
      context.setContentView(ll);
    });
  }

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: 812 / 743
Referenced in: [show references]