我目前在Play商店有一个平板电脑和智能手机运行Android 3.0+(http://tinyurl.com/cnejnjs)的应用程序.为了吸引更多用户,我正在考虑让应用程序在大量设备上运行.
我知道ActionBar Sherlock,这似乎几乎可以做我想要的一切.它没有提供的一件事是我在当前应用程序中使用的搜索小部件.
有没有办法在操作栏中有一个搜索框,它以与默认搜索小部件的工作方式类似的方式更新屏幕上的当前列表片段?
android android-layout android-4.0-ice-cream-sandwich actionbarsherlock android-actionbar
我正在使用一个ViewPager多选题考试应用程序,它从一个更大的集合中随机选择三十个问题.我这样做PageAdapter是为了提供页面ViewPager.
问题是当发生方向改变时,不仅寻呼机而且适配器都被重新加载 - 我知道如何保存当前的寻呼机位置,但是当适配器被重置时,它也会从集合中选择新的问题.处理这个问题的正确方法是什么?
另外,附带问题 - 在RadioGroups上注册选项的最佳方法是什么?直接点击或以不同的方式?
我是Android应用程序开发的新手.
活动:
public class MyActivity extends SherlockActivity {
ActionBar actionBar;
ViewPager pager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pager = new ViewPager(this);
setContentView(pager);
QuestionsAdapter adapter = new QuestionsAdapter(this);
pager.setAdapter(adapter);
int position = 0;
if (savedInstanceState != null) {
position = savedInstanceState.getInt("Q_NUMBER");
}
pager.setCurrentItem(position);
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
int position = pager.getCurrentItem();
savedInstanceState.putInt("Q_NUMBER", position);
}
}
Run Code Online (Sandbox Code Playgroud)
适配器:
class QuestionsAdapter extends PagerAdapter {
Context context; …Run Code Online (Sandbox Code Playgroud) 我收到以下错误,
[Twig_Error_Runtime]
An exception has been thrown during the rendering of a template ("You cannot create a service ("templating.helper.assets") of an inactive scope ("request").") in "AcmeMessagingBundle:Comment:email.html.twig".
Run Code Online (Sandbox Code Playgroud)
我正在从symfony 2自定义控制台命令渲染twig模板
下面是我的服务类,它是事件订阅者,我通过symfony console命令触发onCommentAddEmail事件来发送电子邮件,
class NotificationSubscriber implements EventSubscriberInterface
{
private $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public static function getSubscribedEvents()
{
return array(
'comment.add' => array('onCommentAddEmail', 0),
);
}
public function onCommentAddEmail(CommentAddEvent $event)
{
...................
$body = $this->container->get('templating')->render(
'AcmeMessagingBundle:Comment:email.html.twig',
array('template' => $template)
);
.......
}
}
Run Code Online (Sandbox Code Playgroud)
$ body传递给swiftmailer发送电子邮件.
这是我的服务定义,
ACME\MessagingBundle …
我有实体Basket和BasketItem:
/**
* Acme\BasketBundle\Entity\Basket
*
* @ORM\Entity(repositoryClass="Acme\BasketBundle\Repository\BasketRepository")
* @ORM\Table(name="orders")
* @ORM\HasLifecycleCallbacks()
*/
class Basket
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
// ...
/**
* @ORM\OneToMany(targetEntity="BasketItem", mappedBy="order_id",cascade={"all"})
*/
protected $items;
// ...
public function __construct() {
$this->items = new ArrayCollection();
}
/**
* Add item
*
* @param BasketItem $item
*/
public function addItem(BasketItem $item)
{
$key = $this->find($item->getProduct()->getId());
if ($key === false) {
$this->items->add($item);
} …Run Code Online (Sandbox Code Playgroud) 我有三个单选按钮来指定性别,男性女性和其他.我根据用户选择将此数据保存到我的数据库中,男性为1,女性为2,其他为3.这反映在配置文件页面中,现在当我想编辑配置文件时,我想以可编辑的方式自动填充我的配置文件页面的所有字段,用户只更改他想要的字段.虽然我能够从我的数据库中获取性别1,2,3的值,但我无法将指定的单选按钮填充为已选中.我尝试了以下方法:
String M = (c.getString(c.getColumnIndexOrThrow("Gender")));
RadioGroup rb1 = (RadioGroup)findViewById(R.id.radiogroup1);
if(M.equals(1)){
rb1.check(R.id.radiobutton3);
RadioButton rbu1 =(RadioButton)findViewById(R.id.radiobutton3);
rbu1.setChecked(true);
}
else if(M.equals(2)){
rb1.check(R.id.radiobutton4);
RadioButton rbu2 =(RadioButton)findViewById(R.id.radiobutton4);
rbu2.setChecked(true);
}
else if(M.equals(3)){
rb1.check(R.id.radiobutton5);
RadioButton rbu3 =(RadioButton)findViewById(R.id.radiobutton5);
rbu3.setChecked(true);
}
Run Code Online (Sandbox Code Playgroud) 我想在sqlite android数据库中增加一列.我是这样做的:
public void atualiza(String word){
this.db.rawQuery("UPDATE words SET count = count + 1 WHERE word= ? ", new String[] {word});
}
Run Code Online (Sandbox Code Playgroud)
我在另一个类上调用此方法,如下所示:
this.dh.atualiza(word);
Run Code Online (Sandbox Code Playgroud)
但是当我从模拟器中提取数据库并使用SQLite数据库浏览器进行检查时,该字段不会增加.为什么?
我正在尝试学习Symfony"需要"在命令行/终端中使用php执行某些任务.
我喜欢将我存储php.ini在/apache2/conf目录中,以便将所有服务器配置在一个地方(并且每次我更改内容时都不必处理Windows的UAC).在Apache中,通过设置默认的php.ini位置没有问题
PHPIniDir "C:/apache2/conf"
Run Code Online (Sandbox Code Playgroud)
但是,当从终端运行php时 - 而不是通过apache服务器 - 默认情况下它会在C:\ Windows目录中查找该文件,尽管那里没有:
C:\>php -i
...
Configuration File (php.ini) Path => C:\Windows
Loaded Configuration File => (none)
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
...
Run Code Online (Sandbox Code Playgroud)
当然,我可以通过php -c C:\apache2\conf ...每次使用它来绕过它,但我更喜欢更简单和永久的解决方案.
这可能吗?提前致谢!
我的laravel网站有问题,而我将它托管到在线服务器时会出现错误
您的系统上没有安装合适的CSPRNG
我搜索了这个问题.但我发现没有什么可以帮助我.如果有人知道如何处理这个问题,我将非常感激.谢谢!
该程序使用laravel 5和php 7编码
我最近开始学习symfony框架,我想知道什么是模板系统的最佳选择?
有人建议只使用PHP,但我真的不喜欢它(顺便说一句,看到这篇有趣的文章).
在我开始使用symfony之前,我使用了 - 并且喜欢 - Smarty.
symfony有更好的选择吗?
我正在学习Symfony2的方法,同时为家庭经营的葡萄酒进口商建立一个小型的电子商店.我慢慢了解Symfony2概念,但在继续构建购物车的过程中,我不太确定实现这一点的方法是正确的(至少根据Sf2标准).
我正在寻找的是一个简单的Basket存储BasketItems和它们在会话中的数量,然后在结账时使用这些数据.现在,在我以某种方式将它粘合在一起之前,我想听听关于如何完成和正确分离的建议.
到目前为止,我已经创建了两个实体,现在我不确定我是否应该将逻辑直接放在实体类或存储库中或者最好?
我希望这不是一个太广泛的问题.我很清楚一个真正强大的购物车实施不是一件小事.
在旁注中,是否已经为Symfony2提供了一些经过验证的工作购物篮?
android ×4
php ×4
symfony ×3
android-4.0-ice-cream-sandwich ×1
database ×1
doctrine-orm ×1
increment ×1
laravel-5 ×1
radio-button ×1
sqlite ×1
symfony1 ×1
templates ×1
twig ×1