我是android开发的新手,我一直在使用命令行工具来创建一个android项目.我按照Android开发人员教程中给出的所有说明进行操作.但是,他们更关注IDE用户.
当我尝试从ActionBarActivity而不仅仅是Activity扩展我的MainActivity类时,它引发了以下错误.
错误:包android.support.v7.app不存在
它抱怨这个进口声明.
import android.support.v7.app.ActionBarActivity;
Run Code Online (Sandbox Code Playgroud)
我确保访问SDK管理器,并说安装了Android支持库.我真的很难过这个,我真的很感激你们给我的任何帮助.
这可能会有所帮助:http: //developer.android.com/reference/android/support/v7/app/ActionBarActivity.html
我试图在每次输入模板内容时将输入元素集中在聚合物模板内部。问题是在模板加载之前,我无法选择输入元素。当前,我只是在使用setTimeout来在模板加载后100ms内聚焦输入,但是我想知道是否有更优雅的解决方案。另外,自动聚焦属性不起作用,因为模板可能会取消标记并重新标记很多次。现在,我的代码看起来像这样(在聚合物元素定义内):
Polymer({
// ...
showInput: false,
makeInputVisible: function() {
this.showInput = true;
var container = this.$.container;
setTimeout(function() {
container.querySelector("#input").focus();
}, 100);
},
});
Run Code Online (Sandbox Code Playgroud)
<div id="container">
<template if="{{showInput}}">
<input id="input" is="core-input" committedValue="{{inputValue}}" />
</template>
</div>
Run Code Online (Sandbox Code Playgroud)
但是我更喜欢这样的东西:
Polymer({
// ...
showInput: false,
makeInputVisible: function() {
this.showInput = true;
},
focusInput: function() {
this.$.container.querySelector("#input").focus();
},
});
Run Code Online (Sandbox Code Playgroud)
<div id="container">
<template if="{{showInput}}"
on-stamp="{{focusInput}}">
<input id="input" is="core-input" committedValue="{{inputValue}}" />
</template>
</div>
Run Code Online (Sandbox Code Playgroud)
任何想法表示赞赏。