目前,我使用Rectangle和Rectangle2D(Rectangle2D.Double)交换.
我想知道在选择正确的数据类型时我会考虑什么?我没有看到任何明显的区别,除了Rectangle(Rectangle2D的子类)有更多的API函数.
谢谢.
我是否知道使用特定日期,月份和年份构建日期对象的最有效方法是什么.
Date(int year, int month, int day)
Run Code Online (Sandbox Code Playgroud)
此结构已折旧.因此,我通常做的是:
Calendar calendar = Calendar.getInstance();
Date date = calendar.set(year, month, date).getTime();
Run Code Online (Sandbox Code Playgroud)
但是,我的理解是Calendar.getInstance()相当昂贵.构造Date对象的最有效方法是什么?或者我应该静静地使用Date(int year,int month,int day)而不告诉其余的?
请不要建议使用任何第三方库.
虽然正在记录,但是通过使用"%s",我可以将所选值显示为摘要,但它不能按预期工作.
http://developer.android.com/reference/android/preference/ListPreference.html#getSummary%28%29
我有以下内容 preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/preference_xxx_category">
<CheckBoxPreference
android:title="@string/preference_xxx_mode_title"
android:defaultValue="false"
android:summary="@string/preference_xxx_mode_summary"
android:key="xxxModePreference" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/preference_yyy_category">
<ListPreference
android:title="@string/preference_yyy_mode_title"
android:defaultValue="0"
android:entries="@array/yyy"
android:entryValues="@array/yyy_values"
android:summary="%s"
android:key="yyyModePreference" />
</PreferenceCategory>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
这是我的 arrays.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="yyy">
<item>Display value 0</item>
<item>Display value 1</item>
</string-array>
<string-array name="yyy_values">
<item>0</item>
<item>1</item>
</string-array>
</resources>
Run Code Online (Sandbox Code Playgroud)
我期望通过使用以下Java代码构建完整的首选项活动,使用复选框和列表首选项,每当我执行选择时,列表首选项的摘要文本都可以自动更新.摘要文本将在显示值0和显示值1之间切换.
public class Preferences extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我意识到列表首选项的摘要文本不会自动更新.只有在复选框上执行勾选/取消勾选时,才会使整个活动无效,并且只会更新列表首选项的摘要文本.
因此,我必须修改我的代码如下,这看起来更麻烦.
public class …Run Code Online (Sandbox Code Playgroud) 通过引用bindService(Intent服务,ServiceConnection conn,int标志)
我想知道,我们什么时候应该使用0 flags,什么时候应该要我们用BIND_AUTO_CREATE的flags?该文档没有解释标志0的含义是什么.
flags// Start auto complete service.
autoCompleteServiceIntent = new Intent(AutoCompleteService.class.getName());
startService(autoCompleteServiceIntent);
bindService(autoCompleteServiceIntent, serviceConnection, 0);
Run Code Online (Sandbox Code Playgroud)
BIND_AUTO_CREATEas的示例flagsmContext.bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
mServiceConn, Context.BIND_AUTO_CREATE);
Run Code Online (Sandbox Code Playgroud) 我的理解上Notification.Builder的setTicker是,它会显示在状态栏的文本,即使没有用户'拉下来’的话通知.
根据文件:
设置发送到辅助功能服务的"自动收报机"文本.
但是,在Android 5中,当有传入通知时,它们不再在状态栏中显示文本(仅显示单个应用程序图标).
我想知道,setTicker在Android 5中还有其他用法吗?
目前,我有一个Windows EXE应用程序,有几个加载的DLL.DLL需要通过PostMessage和与我的Windows应用程序通信SendMessage.
Windows EXE应用程序+ DLL都在一个进程中.
该消息应该是EXE和DLL之间的私有.
我想知道,我应该使用
- WM_USER based message
- WM_APP based message
- RegisterWindowMessage
Run Code Online (Sandbox Code Playgroud)
为什么?
如果有一个外部进程(另一个exe),尝试我的Windows应用程序的FindWindow,并发送具有相同ID的消息会发生什么?
我希望不要回复,因为我只对自己进程中的DLL感兴趣.
我来自Java Swing背景.我是否知道为什么使用XML创建GUI在Android中是一个很好的做法?例如,而不是编写代码(这使我感觉更舒服,因为我使用Swing桌面应用程序)
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
Run Code Online (Sandbox Code Playgroud)
我们用XML方式编写代码.
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Run Code Online (Sandbox Code Playgroud)
在教程中,它指出,
使用比在编程布局中使用的更简单的结构和语法,这种结构使得快速构建UI变得非常容易.
但是,我并没有真正购买这个想法,因为我觉得创建一个单独的XML文件更加麻烦.
任何人都可以给出一个真实世界的例子(在Android意义上),为什么使用XML构建GUI比裸Java代码更优越?
如果通过XML进行GUI编程确实很好,为什么它仍然没有成为GUI桌面应用程序开发人员的常见做法?
我参考http://developer.android.com/guide/practices/ui_guidelines/icon_design.html#icon-sets上的文档
因此,我计划拥有以下目录结构.
res/
drawable/
icon.png (? x ? px)
drawable-ldpi/
icon.png (36x36 px)
drawable-mdpi/
icon.png (48x48 px)
drawable-hdpi/
icon.png (72x72 px)
Run Code Online (Sandbox Code Playgroud)
但是,我找不到任何文档,提到默认启动器图标大小的大小.
我可以知道默认的启动器图标大小应该是多少?
String database[] = {'a', 'b', 'c'};
Run Code Online (Sandbox Code Playgroud)
我想基于给定生成以下字符串序列database.
a
b
c
aa
ab
ac
ba
bb
bc
ca
cb
cc
aaa
...
Run Code Online (Sandbox Code Playgroud)
我只能想到一个非常"虚拟"的解决方案.
public class JavaApplication21 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
char[] database = {'a', 'b', 'c'};
String query = "a";
StringBuilder query_sb = new StringBuilder(query);
for (int a = 0; a < database.length; a++) {
query_sb.setCharAt(0, database[a]);
query = query_sb.toString();
System.out.println(query);
}
query = "aa";
query_sb = …Run Code Online (Sandbox Code Playgroud) 以前,当我想要滚动ListView到所需位置时,我会使用
listView.setSelection(row);
Run Code Online (Sandbox Code Playgroud)
在ListView没有任何动画将滚动- Android的列表视图设置默认位置,而动画
现在,我希望达到同样的效果RecyclerView.我尝试表演
((LinearLayoutManager)recyclerView.getLayoutManager()).scrollToPositionWithOffset(row, 0);
Run Code Online (Sandbox Code Playgroud)
但是,有滚动动画,我想避免.
有没有什么办法可以在没有动画的情况下以编程方式滚动?
这是我的意思 - https://youtu.be/OKsUKwBLoks
注意,我已经尝试过以下方法.所有这些都会生成动画.
android ×6
java ×4
algorithm ×1
c++ ×1
combinations ×1
mfc ×1
permutation ×1
windows ×1
xml ×1