Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19869] Android: Support adding native UI elements to Ti.UI.View subclasses

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-11-05T20:59:57.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0
ComponentsAndroid, Hyperloop
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2015-11-04T19:04:23.000+0000
Updated2016-07-22T01:06:11.000+0000

Description

Be able to pass in some subclass of android.view.View into Titanium methods that take Ti.UI.View subclasses (i.e. Ti.Ui.View.add())

Comments

  1. Christopher Williams 2015-11-05

       var FrameLayout = require('android.widget.FrameLayout'),
       	LayoutParams = require('android.widget.FrameLayout.LayoutParams'),
       	ViewGroupLayoutParams = require('android.view.ViewGroup.LayoutParams'),
       	Gravity = require('android.view.Gravity'),
       	Activity = require('android.app.Activity'),
       	activity = new Activity(Ti.Android.currentActivity),
       	main,
       	win = Ti.UI.createWindow(),
       	view = Ti.UI.createView();
       
       // Create a native layout to add our boxes to
       main = new FrameLayout(activity);
       main.setLayoutParams(new LayoutParams(ViewGroupLayoutParams.MATCH_PARENT, ViewGroupLayoutParams.MATCH_PARENT, Gravity.TOP));
       
       // Add our layout to the Ti.UI.View
       view.add(main);
       win.add(view);
       
  2. Lokesh Choudhary 2016-07-14

    [~cwilliams], When I use the code above I get error :
       [ERROR] :  TiExceptionHandler: (main) [98,98] ----- Titanium Javascript Runtime Error -----
       [ERROR] :  TiExceptionHandler: (main) [0,98] - In ti:/module.js:280,9
       [ERROR] :  TiExceptionHandler: (main) [0,98] - Message: Uncaught Error: Requested module not found: android.widget.FrameLayout
       [ERROR] :  TiExceptionHandler: (main) [0,98] - Source: 		throw new Error("Requested module not found: " + request);
       
  3. Lokesh Choudhary 2016-07-22

    Verified the implementation. Closing. Environment: Appc Studio : 4.7.0.201607111053 Ti SDK : 5.4.0.v20160720201924 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.5 Appc NPM : 4.2.8-1 Appc CLI : 5.4.0-33 Node: 4.4.4 Nexus 5 - Android 6.0.1

JSON Source