我正在尝试获取按值排序的结果 HashMap。
这是 HashMap 的键和值:
map.put("ertu", 5);
map.put("burak", 4);
map.put("selin", 2);
map.put("can", 1);
Run Code Online (Sandbox Code Playgroud)
我试图得到这样的结果:
1 = can
2 = selin
4 = burak
5 = ertu
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import java.util.*;
public class mapTers {
public static void main(String[] args) {
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put("ertu", 5);
map.put("burak", 4);
map.put("selin", 2);
map.put("can", 1);
Integer dizi[] = new Integer[map.size()];
Set anahtarlar = map.keySet();
Iterator t = anahtarlar.iterator();
int a = 0;
while (t.hasNext()) {
dizi[a] = map.get(t.next());
a++;
}
Arrays.sort(dizi); …Run Code Online (Sandbox Code Playgroud) 我曾经能够做到这一点:
<string name="foo">white <font fgcolor="#ff6890a5">blue</font></string>
Run Code Online (Sandbox Code Playgroud)
但现在它不再起作用了.它似乎是整数解析代码中的一个错误; 请参阅https://code.google.com/p/android/issues/detail?id=58192
问题是,我收到客户的投诉现在 ; 我不能等待修复bug.
有没有人知道解决方法,例如使用color.xml中的命名资源或类似的东西?
ETA:我发现它fgcolor="blue"仍然有效,但它是错误的蓝色阴影.某处是否有合法颜色名称列表?也许我能找到一个足够接近的人.如果颜色是没有高位设置的数字,它也可以工作#7f6890a5,但当然这太微弱而无用; 我需要纯色,而不是半透明.
ETA:浏览源代码显示以下颜色:
aqua 0x00FFFF
black 0x000000
blue 0x0000FF
fuchsia 0xFF00FF
green 0x008000
grey 0x808080
lime 0x00FF00
maroon 0x800000
navy 0x000080
olive 0x808000
purple 0x800080
red 0xFF0000
silver 0xC0C0C0
teal 0x008080
white 0xFFFFFF
yellow 0xFFFF00
Run Code Online (Sandbox Code Playgroud)
这并不能解决我的问题,但也许其他人在这个问题上搜索可能会发现这些信息很有用.
我正在使用 repo 来构建 Android。我想从以前的版本构建(例如上个月的构建#1234)。我做了这样的事情:
我从清单的特殊副本开始,它明确设置了每个包的修订版本:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
...
<project name="packages/apps/Browser" revision="f42301ffb36a68fadffdb87fa1bdc09aceac53cb"/>
<project name="packages/apps/Calculator" revision="481a23ed78397e35201de3638ec0d76797b77d25"/>
<project name="packages/apps/Calendar" revision="19a0737be4d51aa71a0d122f5f24ab7e53869398"/>
<project name="packages/apps/Camera" revision="67e6c190f82f0f7b8704fe5663eb92082c4cc943"/>
...
</manifest>
Run Code Online (Sandbox Code Playgroud)
这基本上是 default.xml 的副本,但为创建 build #1234 时的提交明确指定了每个包的修订版本。
所以现在我发出命令
cp ~/manifest-build-1234.xml .repo/manifests
repo init -m manifest-build-1234.xml
repo sync
Run Code Online (Sandbox Code Playgroud)
结果:一些软件包被设置为清单中指定的修订版本,但其他一些软件包仍保留在先前的头部。
如果我完全删除这些包,然后执行另一个操作repo sync,那么这些包将以正确的版本检出。
所以我的问题是:除了在执行之前删除所有内容之外repo sync,我如何保证所有包都以正确的版本签出?
我的应用程序始终使用DeviceId作为唯一标识符,这当然需要READ_PHONE_STATE作为权限。过去还可以,但是现在我已迁移到Marshmellow 23,在这里请求此权限会在运行时显示一个非常可怕的对话框,说...
“允许{我的应用}拨打和管理电话吗?”
对于只想获取deviceId的应用程序来说,这是一条非常可怕的消息。
我正在考虑切换到Android ID,因为它不需要任何许可。
String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
Run Code Online (Sandbox Code Playgroud)
谷歌搜索,我发现使用android ID时遇到了一些问题,但这都是陈旧的东西。在Froyo时代,有一家电话供应商为其所有电话生成相同的ID,但这就是我所看到的全部。
有人知道使用Android ID有任何问题吗?谢谢院长
我正在将模块从 Eclipse 移植到 Android Studio/Gradle,并且需要指定源、资源和清单的位置:
sourceSets {
main {
manifest {
srcFile './AndroidManifest.xml'
}
java {
srcDirs = ["src"]
}
resources {
srcDirs = ["resource"]
}
}
}
Run Code Online (Sandbox Code Playgroud)
javaAndroid Studio/Gradle 似乎对我的和条目非常满意,但对我的条目resources犹豫不决:manifest
No signature of method: build_b4wnchd9ct4a5qt388vbbtbpz.sourceSets() is applicable for argument types: (build_b4wnchd9ct4a5qt388vbbtbpz$_run_closure2) values: [build_b4wnchd9ct4a5qt388vbbtbpz$_run_closure2@35290d54]
Run Code Online (Sandbox Code Playgroud)
我所有的谷歌搜索和搜索都表明这应该有效。
北极狐,2020年3月1日。不确定 Gradle 附带了哪个版本。
我正在建造俄罗斯方块,我很困惑如何制作一块硬件.
我尝试向hardDrop()Board类添加一个方法,该方法将从底行迭代并检查开放空间...
董事会类:
public int hardDrop() {
int hardDropRow = 0;
for(int row = totalRows-1; row > 0; row--) {
for(int col = 0; col < grid[row].length; col++) {
if (grid[row][col] != null) {
hardDropRow = row;
return hardDropRow;
}
}
}
return hardDropRow;
}
Run Code Online (Sandbox Code Playgroud)
件类:
然后在这里,我将每件作品添加dropRow到getRow():
//Hard drop
if (keycode == KeyEvent.VK_UP) {
//get next valid coordinates nearest to bottom
//hard drop needs to which row the piece needs to drop to
int …Run Code Online (Sandbox Code Playgroud) 嗨,目前我正在尝试在 android 中构建我的项目,但我一直收到这个
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
java.io.IOException: Could not delete folder C:\Users\Henry\Desktop\Andriod\World\GATES\app\build\intermediates\transforms\dex\debug\folders\1000
Run Code Online (Sandbox Code Playgroud)
即使我决定自己删除文件夹,我也得到了这个
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
java.io.IOException: Could not create empty folder C:\Users\Henry\Desktop\Andriod\World\GATES\app\build\intermediates\transforms\dex\debug
Run Code Online (Sandbox Code Playgroud)
然后我修复了我的依赖项以调试认为可以解决它但得到了这个
Error:Execution failed for task ':app:generateDebugBuildConfig'.
java.io.IOException: Could not delete folder C:\Users\Henry\Desktop\Andriod\World\GATES\app\build\generated\source\buildConfig\debug\com\ant
Run Code Online (Sandbox Code Playgroud)
我该如何解决所有这些烂摊子,而且 google 上似乎很少出现此类问题
有没有人能够通过https使用ksoap2 android连接到肥皂服务器?
我一直收到"主机名<###>未经验证"的错误
我正在做
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport (URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Run Code Online (Sandbox Code Playgroud)
显然回顾其他ksoap不是为了你的安慰我们给我们一个不同的通过https连接的电话,但我找不到在Android版本中做到这一点的方法.
有人找到了一种关于或知道使用呼叫的方法吗?
谢谢你的帮助
我想实现一个在特定端口上接收SMS的应用程序.
清单代码:
<receiver android:name=".BinarySMSReceiver">
<intent-filter>
<action android:name="android.intent.action.DATA_SMS_RECEIVED"/>
<data android:port="8091"/>
<data android:scheme="sms"/>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
接收器类代码如下.
public class BinarySMSReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
if(null != bundle)
{
String info = "Binary SMS from ";
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
byte[] data = null;
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
info += msgs[i].getOriginatingAddress();
info += "\n*****BINARY MESSAGE*****\n";
data = msgs[i].getUserData();
for(int index=0; …Run Code Online (Sandbox Code Playgroud) 我上传了一个文本文件(*.txt)到服务器,现在我想读取文本文件...
没试好我试过这个例子.
ArrayList<String> urls=new ArrayList<String>(); //to read each line
TextView t; //to show the result
try {
// Create a URL for the desired page
URL url = new URL("mydomainname.de/test.txt"); //My text file location
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
t=(TextView)findViewById(R.id.TextView1);
String str;
while ((str = in.readLine()) != null) {
urls.add(str);
}
in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
t.setText(urls.get(0)); // My TextFile has 3 lines …Run Code Online (Sandbox Code Playgroud) android ×8
java ×4
build.gradle ×1
collections ×1
gradle ×1
hashmap ×1
ksoap2 ×1
map ×1
repository ×1
sms ×1
soap ×1
sorting ×1