嗨,我正在开发Android应用程序开发.我正在使用Titanium studio进行开发.我创建了一个简单的应用程序.我想在我的应用程序中捕获设备后退按钮事件,因为我不想在钛中使用android默认选项卡.我正在创建自己的选项卡.我尝试了以下代码:
:list.js
var expt = Titanium.UI.currentWindow;
expt.addEventListener('android:back', function (e)
{
Ti.App.fireEvent('expt_back_event');
});
Run Code Online (Sandbox Code Playgroud)
:app.js
Ti.App.addEventListener('expt_back_event',function(e)
{
alert('hiiii in side event listener');
});
Run Code Online (Sandbox Code Playgroud)
但它没有工作而不是弹出它关闭了我不想要的应用程序.有没有办法获得这个结果.
android back-button-control appcelerator-mobile titanium-mobile
我正在开发小型Android应用程序,其中我正在使用带有一些菜单项的操作栏.一个菜单项包含子菜单.现在我想做的是始终显示带有文本和图标的菜单项.
我按照以下方式定义菜单项.
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/card_menu"
android:icon="@drawable/abc"
android:showAsAction="withText|always"
android:title="cards">
<menu>
<item
android:id="@+id/C1"
android:title="C1"/>
<item
android:id="@+id/C2"
android:title="c2"/>
<item
android:id="@+id/C3"
android:title="C3"/>
</menu>
</item>
<item
android:id="@+id/notification"
android:actionLayout="@layout/notification_icon"
android:icon="@drawable/notification"
android:showAsAction="always"
android:title="Notifications"/>
<item
android:id="@+id/filter"
android:icon="@drawable/filter"
android:showAsAction="always"
android:title="Filter"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
现在发生的事情是我的动作栏正确显示我的物品; 唯一的事情是,当窗口处于纵向模式时,它仅显示图像,当窗口处于横向模式时,它显示图像和文本.但我想要两种模式下的图像和文字.
怎么做?有什么方法可以解决这个问题吗?
嗨,我正在开发一个Android应用程序.在我的应用程序中,我正在使用ActionBarSherlock.我在动作栏中定义了几个菜单项,方法如下:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/card_menu"
android:title="cards"
android:showAsAction="always"
android:actionLayout="@layout/action_button"
>
<menu>
<item android:id="@+id/C1"
android:title="C1" />
<item android:id="@+id/C2"
android:title="c2" />
<item android:id="@+id/C3"
android:title="C3" />
</menu>
</item>
<item android:id="@+id/notification"
android:title="Notifications"
android:showAsAction="always"
android:actionLayout="@layout/notification_icon"
android:icon="@drawable/notification"
/>
<item android:id="@+id/filter"
android:icon="@drawable/filter"
android:title="Filter"
android:showAsAction="always"
/>
Run Code Online (Sandbox Code Playgroud)
现在,一切都显示得很好,但我的问题是,当我点击card_menu项目,我定义子菜单,并定义一个动作布局; 它没有显示那些子菜单.
我的其他菜单项工作正常.只有当我为包含子菜单的项目定义动作布局时,我才能显示子菜单.
如果我删除动作布局,那么它工作正常......
我知道如果我们为项目定义一个动作布局,那么我们必须手动处理点击监听器.我这样做的方式如下:
final MenuItem item = menu.findItem(R.id.card_menu);
item.getActionView().setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onOptionsItemSelected(item);
Toast.makeText(getActivity(), "click on menu", Toast.LENGTH_SHORT).show();
}
});
Run Code Online (Sandbox Code Playgroud)
我能够处理该项目的click事件,但无法显示下拉子菜单项.
如何解决这个问题呢?如何打开子菜单?
需要帮助....谢谢......
您好我正在构建一个具有一些材料设计概念的Android示例应用程序.我从https://developer.android.com/training/material/theme.html开始.我正在使用eclipse.我在我的项目的库部分添加了appcompat_7支持库.然后当我尝试应用以下主题时.
<style name="AppTheme" parent="@android:style/Theme.Material.Light">
</style>
Run Code Online (Sandbox Code Playgroud)
它给我以下运行时错误:
11-12 11:32:30.416: E/AndroidRuntime(21375): java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.androidmaterialdesignapi/com.example.androidmaterialdesignapi.MainActivity}:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
Run Code Online (Sandbox Code Playgroud)
我的活动延伸了ActionBarActivity.我做错了什么.需要一些帮助.谢谢.学习材料设计有什么好的例子吗?
我正在开发小型Android应用程序,其中我使用我的自定义线性布局类.在那个课程中,我试图绘制一个小三角形并尝试将其包含在我的线性布局中,但我无法做到这一点.我试着以下方式...
@SuppressLint("DrawAllocation")
public class SimpleLin extends LinearLayout {
public String TAG = "CustomviewActivity";
LinearLayout parentLayout;
public SimpleLin(Context context)
{
super(context);
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(inflater != null){
view = inflater.inflate(R.layout.main2, this);d.lin_llt);
parentLayout.setBackgroundResource(R.drawable.bcd);
}
}
public SimpleLin(Context context, AttributeSet attrs) {
super( context, attrs );
context1= context;
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Log.i("############################", "inside ondraw");
Paint p = new Paint();
p.setStyle(Style.FILL);
p.setColor(Color.RED);
Point point = new Point();
point.x = 80;
point.y = 80;
Path path = getEquilateralTriangle(point, 70, Direction.SOUTH); …Run Code Online (Sandbox Code Playgroud) 我正在开发一个小型Android应用程序,我希望在其中具有Geolocation功能.我想要编码的是一种服务,它提供用户的更新位置,无论他们是否正在使用我的应用程序.
我知道,如果我不断检查用户的位置,它会耗尽设备的电池,所以我想要很好的解决方案.例如,每隔5或10分钟给我更新一次.我已经阅读了很多这个问题,但我想得到一个好的解决方案.
我读了这个页面,如果用户正在使用我的应用程序,但如果用户没有使用我的应用程序那么这是一个很好的解决方案,那么我该怎么办?我该如何解决这一挑战?
嗨,我正在开发Android应用程序,我希望用户当前位置足够准确.所以我有2个选项来实现这一个
检索当前位置.http://developer.android.com/training/location/retrieve-current.html
和
接收位置更新 http://developer.android.com/training/location/receive-location-updates.html
所以这是我的问题.我经历了检索当前位置,我意识到最后它给了我用户最后知名的位置.但我的要求是用户当前位置.
所以我走向接收位置更新.我虽然可以获得第一次更新,但我会停止更新.但这也是第一次它给了我最后的位置而不是新的位置.并在第一次阅读后启动gps以提供连续更新.但我只对第一次更新感兴趣.
所以我需要一个好的解决方案,它会给我用户准确的当前位置.使用gps或网络或wifi任何可用的.
如果我做错了什么,请更正.需要帮忙.谢谢.
嗨,我正在开发Android应用程序,我正在使用Twitter登录.我正在使用twitter4j-3.0.5 lib进行twitter身份验证.所以我的场景是这样的,登录成功后它回到我的应用程序,但在后台它没有关闭浏览器窗口.当我用推特窗口点击后退我的浏览器时仍然存在.
我的代码看起来像这样:
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(requestToken.getAuthenticationURL()));
startActivity(intent);
<activity
android:name="com.example.twitterapp.TwitterWebActivity"
android:label="@string/title_activity_twitter_web" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="com.example.twitterapp"
android:scheme="oauth" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我想关闭该Web浏览器.有人可以帮我吗?需要帮忙.比你.
我正在尝试将数组作为参数传递给我的控制器方法,但它不适用于我.我通过以下方式尝试了它:
http://localhost:3000/med?med_ids=[2,1]
Run Code Online (Sandbox Code Playgroud)
我也尝试了以下方式,并为我工作.我只是想知道任何好的解决方案
http://localhost:3000/manufacturer/1/medicines?medicine_id[]=2&medicine_id[]=1
Run Code Online (Sandbox Code Playgroud)
内部控制器:
@val = params[:medicine_id]
Run Code Online (Sandbox Code Playgroud)
值即将到来,但我想将其作为数组.
需要一些帮助.谢谢.
嗨,我正在开发Android应用程序的快捷方式.我的代码看起来像
private void setShortMenu() {
ArrayList<ShortcutInfo> shortcutInfos = new ArrayList<>();
Intent intent = new Intent(this, SampleActivity2.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("val",1);
intent.addCategory("android.shortcut.conversation");
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id2")
.setShortLabel("Web site")
.setLongLabel("Open the web site")
.setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
.setIntent(intent)
.build();
shortcutInfos.add(shortcut);
Intent intent2 = new Intent(this, SampleActivity3.class);
intent2.setAction(Intent.ACTION_VIEW);
intent.addCategory("android.shortcut.conversation");
intent.putExtra("val",2);
ShortcutInfo shortcut2 = new ShortcutInfo.Builder(this, "id1")
.setShortLabel("Web site...")
.setLongLabel("Open the web site...")
.setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
.setIntent(intent2)
.build();
shortcutInfos.add(shortcut2);
shortcutManager.setDynamicShortcuts(shortcutInfos);
}
Run Code Online (Sandbox Code Playgroud)
我的清单看起来像这样:
<application
android:name=".SampleApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" …Run Code Online (Sandbox Code Playgroud) shortcuts android android-activity android-static-shortcuts android-dynamic-shortcuts