我在从Android中的相册导入图片时遇到问题,因为onActivityResult()从不调用该方法.
这是我写的代码(从片段调用而不是活动):
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
getActivity().startActivityForResult(galleryIntent, PICK_IMAGE);
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我已经定义了onActivityResult()但它永远不会触发:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult"); // not printed
}
Run Code Online (Sandbox Code Playgroud)
知道这有什么问题吗?
谢谢!
我只想加1天DateTime.所以我写道:
DateTime date = new DateTime(2010, 4, 29, 10, 25, 00);
TimeSpan t = new TimeSpan(1, 0, 0, 0);
date.Add(t);
Console.WriteLine("A day after the day: " + date.ToString());
Run Code Online (Sandbox Code Playgroud)
我认为结果将是:2010 04 30- 10:25:00但我仍然得到了初始日期.
怎么了?
我正在寻找在rails中编写迁移的方法,这些方法可以多次针对数据库执行而不会失败.
比如说我有这个迁移:
class AddUrlToProfile < ActiveRecord::Migration
def self.up
add_column :profile, :url, :string
end
def self.down
remove_column :profile, :url
end
end
Run Code Online (Sandbox Code Playgroud)
如果该url列已存在于Profile表中(例如,如果schema.rb已被意外修改),我的迁移将失败,说它是重复的!
那么如果必须执行此迁移呢?
谢谢
我想知道,有什么指导方针,我们如何选择ArrayAdapter和SimpleAdapter.
对于每个列表项,它们将由几个TextViews和Views呈现,这些布局很好.通过使用ArrayAdapter或,我意识到我可以毫无问题地实现它们SimpleAdapter.
我们如何选择它们是否有任何指导方针?我的猜测是
ArrayAdapter使我们能够动态添加新项目,即使在此期间显示列表后也是如此.注意,ArrayAdapter有方法add.SimpleAdapter 用于大小写,一旦显示列表,就不能再添加新项目了.这是我们应该遵循的准则吗?
我正在尝试控制安装在远程计算机中的Windows服务.我正在ServiceController上课.
我有这个:
ServiceController svc = new ServiceController("MyWindowsService", "COMPUTER_NAME");
Run Code Online (Sandbox Code Playgroud)
有了这个,我可以像这样得到Windows服务的状态:
string status = svc.Status.ToString();
Run Code Online (Sandbox Code Playgroud)
但我无法控制Windows服务(通过执行svc.Start();或svc.Stop();).我得到以下异常:
无法在计算机'COMPUTER_NAME'上打开Servicexxx服务
这是正常的,我想这与访问权限有关.但是怎么样?我看过谷歌但没找到我想要的东西.但是我经常阅读与假冒相关的内容,但我不知道这意味着什么.
注意:本地和远程计算机都运行Win XP Pro.
我想知道?C#中的含义是什么?
我看到的东西是:DateTime?或者int?.我想这是特定于C#4.0的?
我不能在谷歌找它,因为我不知道这个东西的名字.
问题是我使用的日期时间和我有很多投的错误(从DateTime到DateTime?).
谢谢
我试图解析一个约会,但我奇怪地得到一个例外.
这是代码:
import java.util.Date;
String strDate = "Wed, 09 Feb 2011 12:34:27";
Date date;
SimpleDateFormat FORMATTER = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
try {
date = FORMATTER.parse(strDate.trim());
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
例外是:
java.text.ParseException:无法解析的日期:"Wed,09 Feb 2011 12:34:27",位于DateTest.main的java.text.DateFormat.parse(DateFormat.java:337)(DateTest.java:17)
我已阅读文档,我认为我的模式是正确的.所以我不明白......
任何的想法?
谢谢!
我正在访问一个我无法更改的数据库,它有一个名为valid defined 的列.每当我尝试访问属性时,我都会遇到以下异常:
有效?由ActiveRecord定义(ActiveRecord :: DangerousAttributeError)
异常是有道理的,但由于我无法更改数据库,如何解决此错误?
我尝试"覆盖"该属性,但我不知道如何删除原始列.我可以成功调用这个valid_column方法,但是每当我尝试访问数据库中定义的另一个属性时,我都会得到相同的异常.它似乎仍在尝试映射有效列.
def valid_column=(valid)
write_attribute(:valid, valid)
end
def valid_column
read_attribute(:valid)
end
Run Code Online (Sandbox Code Playgroud)
我不确定这是否重要,但以下是我的环境的详细信息:
提前致谢!
我是Ruby的新手,我一直在努力学习Rake,RSpec和Cucumber.我发现了一些代码可以帮助我测试我的Rake任务,但是我无法让它工作.我在这里被告知:http://blog.codahale.com/2007/12/20/rake-vs-rspec-fight/放弃这个:
def describe_rake_task(task_name, filename, &block)
require "rake"
describe "Rake task #{task_name}" do
attr_reader :task
before(:all) do
@rake = Rake::Application.new
Rake.application = @rake
load filename
@task = Rake::Task[task_name]
end
after(:all) do
Rake.application = nil
end
def invoke!
for action in task.instance_eval { @actions }
instance_eval(&action)
end
end
instance_eval(&block)
end
end
Run Code Online (Sandbox Code Playgroud)
进入我的spec_helper.rb文件.
我已经设法把这个代码拿出来并在我的黄瓜步骤中运行它:
When /^I run the update_installers task$/ do
@rake = Rake::Application.new
Rake.application = @rake
load "lib/tasks/rakefile.rb"
@task = Rake::Task["update_installers"]
for action in @task.instance_eval { @actions } …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用单选按钮作为选项卡.
我为它加载了图像,但是它们朝向左侧对齐.如何使它们在中心对齐.

这就是我的XML文件的外观
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dip"
android:background="#fff"/>
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:checkedButton="@+id/allcontacts"
android:id="@+id/contactgroup">
<RadioButton android:id="@+id/allcontacts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"/>
<RadioButton
android:id="@+id/categories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"/>
<RadioButton android:id="@+id/favourites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1" />
</RadioGroup>
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" android:visibility="gone" />
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)