我在我的选项卡Activity中覆盖了以下方法,它可以正常工作,但我希望每个片段都有特定的选项菜单.当我把它放在我的片段中并按下菜单按钮时,没有任何反应.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.activity_calc, menu);
return true;
}
Run Code Online (Sandbox Code Playgroud) android android-fragments android-optionsmenu actionbarsherlock
我有一个带标签的ViewPager + ActionBar.当我"滑动"到另一个标签时,我想隐藏软键盘,但我无法弄清楚如何.
我已经将我的Activity传递给了FragmentPageAdapter的构造函数,所以我可以调用它
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Run Code Online (Sandbox Code Playgroud)
但它没有做任何事情(并且它位于代码的可到达区域)...帮助?
android android-softkeyboard android-fragments android-viewpager
我在线观看所有这些Android教程,并且越来越多地进入Android编程,我发现每次都要去File> New> Other> Android> Android Project是一件轻微的麻烦,特别是当我这个人的时候我看着他们的.
如果有人可以为我提供Android Project(和Android XML文件)放在"New"菜单上的方法,那将会非常有帮助.
谢谢
我有一些库项目有自己的测试.我不负责这个库项目并且不关心它的测试,但是,当我运行gradle :app:connectedCheck
它时运行我的测试但它也运行依赖项的测试.有什么办法可以阻止这个吗?
我应该提一下,我的依赖关系不在app
我所说的模块中.
编辑:更具体地说,我依赖的图书馆项目有非常长的测试,因为他们打算在凌晨2点在构建服务器上运行,所以我坐在这里等待油漆干燥只是为了让我真的很短试验.
EDIT2:我也尝试过使用Spoon.我现在已经安装它并可以运行单个类,但我想在一个包中运行所有内容.那可能吗?
编辑3:文件夹结构是无关紧要的,但这是一个非常非常详细的外观:
root
-some_library_project
-main_project
-settings.gradle
Run Code Online (Sandbox Code Playgroud)
main_project build.gradle看起来像这样.我应该提一下勺子目前什么都不做,但我的选择是开放的:
buildscript{
repositories {
jcenter()
}
dependencies{
classpath 'com.stanfy.spoon:spoon-gradle-plugin:0.10.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'spoon'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.something.main_project"
minSdkVersion 17
targetSdkVersion 20
versionCode 1
versionName "1.0"
testPackageName "com.something.main_project.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
signingConfigs {
debug {
storeFile file("debug.keystore")
}
release {
storeFile file("release.keystore")
storePassword "something"
keyAlias "something"
keyPassword "something"
}
}
buildTypes {
release {
runProguard false …
Run Code Online (Sandbox Code Playgroud) 在Java中,我能做到
BigInteger b = new BigInteger(500);
Run Code Online (Sandbox Code Playgroud)
然后按照我的喜好格式化它
b.toString(2); //binary
b.toString(8); //octal
b.toString(10); //decimal
b.toString(16); //hexadecimal
Run Code Online (Sandbox Code Playgroud)
在C#中,我可以做到
int num = int.Parse(b.ToString());
Convert.ToString(num,2) //binary
Convert.ToString(num,8) //octal
Run Code Online (Sandbox Code Playgroud)
但我只能用long
价值观做得更小.是否有一些方法可以打印具有指定基数的BigInteger?我发布了这个,BigInteger Parse Octal String?,昨天收到了如何将基本上所有字符串转换为BigInteger值的解决方案,但是没有成功输出.
所以我正在使用罗盘角度(以度为单位)进行应用.我已经设法确定角度均值的计算,使用以下内容(可在http://en.wikipedia.org/wiki/Directional_statistics#The_fundamental_difference_between_linear_and_circular_statistics中找到):
double calcMean(ArrayList<Double> angles){
double sin = 0;
double cos = 0;
for(int i = 0; i < angles.size(); i++){
sin += Math.sin(angles.get(i) * (Math.PI/180.0));
cos += Math.cos(angles.get(i) * (Math.PI/180.0));
}
sin /= angles.size();
cos /= angles.size();
double result =Math.atan2(sin,cos)*(180/Math.PI);
if(cos > 0 && sin < 0) result += 360;
else if(cos < 0) result += 180;
return result;
}
Run Code Online (Sandbox Code Playgroud)
所以我正确地得到了我的平均值/平均值,但是我无法获得正确的方差/ stddev值.我很确定我正在计算我的方差不正确,但想不出正确的方法.
这是我如何计算方差:
double calcVariance(ArrayList<Double> angles){
//THIS IS WHERE I DON'T KNOW WHAT TO PUT
ArrayList<Double> normalizedList = …
Run Code Online (Sandbox Code Playgroud) 例如,如果我想要所有长度为3的二进制字符串,我可以简单地将它们声明为:
boolean[] str1 = {0,0,0};
boolean[] str2 = {0,0,1};
boolean[] str3 = {0,1,0};
boolean[] str4 = {0,1,1};
boolean[] str5 = {1,0,0};
boolean[] str6 = {1,0,1};
boolean[] str7 = {1,1,0};
boolean[] str8 = {1,1,1};
Run Code Online (Sandbox Code Playgroud)
将所有可能的长度为N的二进制字符串生成到布尔数组中的最有效方法是什么?
我不一定需要的最有效的方法,只有一个那是相当有效的,并容易让我多线程.
编辑:我应该注意,如果重要的话,我将把它们全部存储在ArrayList中.
所以我在eclipse中编辑Android XML时已经(并且遇到过)这个问题.我已经尝试了不同版本的eclipse和不同的Android SDK以及整个重新下载等等但仍然出现此错误.当在eclipse中编辑XML时,以某种不可预测的方式,文本会随机明显地错位自己.文本本身仍然在同一个地方,但它被渲染到不同的地方.除非我完全重启eclipse,否则问题不会消失.
下面的三张图片都是完全相同的文件,没有任何修改.
这张照片是我选择全部时的外观(ctrl + A)
这张照片是我取消选择时的样子
最后一个是我重启eclipse时的样子.请注意,这是正确的外观,它应该一直这样.
我已经经历了很长一段时间的这些问题而且非常恼火.我也多次重新安装了Windows-7 x64,问题从未消失.请帮忙?
所以我有四个按钮,它们都使用match_parent来表示高度和宽度.我使用"drawableTop"属性在按钮本身内有图像,我想制作它,所以我不需要为每个分辨率单独的图像.这是我拍的肖像截图.景观将会有所改变.
所以这看起来很好,除了我只有4种不同的图像分辨率,并在我的手机上尝试它们没有产生积极的结果.有没有什么方法可以让我有一个更大的图像,比如只是"可绘制"并让它缩小以适应所有分辨率?如果没有,我该怎么办?我目前涵盖hdpi,ldpi,mdpi和xhdpi,但我想涵盖所有界限.还有哪些其他密度?
如果我可以实现自动调整大小,我也不必禁止用户使用Landscape:
另外,这是xml:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
tools:ignore="NestedWeights" >
<Button
android:id="@+id/bMap"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableTop="@drawable/ic_camera"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:id="@+id/bCamera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableTop="@drawable/ic_camera"
android:text="Button" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
tools:ignore="NestedWeights" >
<Button
android:id="@+id/bGallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableTop="@drawable/ic_camera"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:id="@+id/bPlants"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableTop="@drawable/ic_camera"
android:text="Button" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在Java中,我能做到
//Parsing Octal String
BigInteger b = new BigInteger("16304103460644701340432043410021040424210140423204",8);
Run Code Online (Sandbox Code Playgroud)
然后按照我的喜好格式化它
b.toString(2); //2 for binary
b.toString(10); //10 for decimal
b.toString(16); //16 for hexadecimal
Run Code Online (Sandbox Code Playgroud)
C#BigInteger
提供了上面显示的格式化功能,但我似乎无法找到解析BIIIG(大于64位,无符号)八进制值的方法.