Java tutorial
/** * This file was auto-generated by the Titanium Module SDK helper for Android * Appcelerator Titanium Mobile * Copyright (c) 2009-2013 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the Apache Public License * Please see the LICENSE included with this distribution for details. * */ package com.alcoapps.navigationdrawer; import org.appcelerator.kroll.KrollModule; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiApplication; //import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.kroll.common.Log; import android.R; import android.app.Activity; import android.app.ActionBar; import android.os.Bundle; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; @Kroll.module(name = "Navdrawer", id = "com.alcoapps.navigationdrawer") public class NavdrawerModule extends KrollModule { // Standard Debugging variables private static final String TAG = "NavdrawerModule"; // You can define constants with @Kroll.constant, for example: // @Kroll.constant public static final String EXTERNAL_NAME = value; public NavdrawerModule() { super(); } @Kroll.onAppCreate public static void onAppCreate(TiApplication app) { Log.d(TAG, "inside onAppCreate"); // put module init code that needs to run when the application is created } // Methods @Kroll.method public void attach() { // as a first step I'll play around with the actual activity and actionbar to make sure // I can properly get access to it // some feedback is always nice Log.d(TAG, "called the attach method"); // declare stuff TiApplication appContext = TiApplication.getInstance(); Activity activity = appContext.getCurrentActivity(); ActionBar actionBar; if (!TiApplication.isUIThread()) { // Within which the entire activity is enclosed //DrawerLayout mDrawerLayout; // ListView represents Navigation Drawer //ListView mDrawerList; // ActionBarDrawerToggle indicates the presence of Navigation Drawer in the action bar //ActionBarDrawerToggle mDrawerToggle; // Play with the action bar String mTitle = "This is a test"; String mSubtitle = "This is the subtitle"; actionBar = activity.getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setSubtitle(mSubtitle); actionBar.setTitle(mTitle); } } }