我长时间在分支上开发后切换到了主人.日志显示:
您的分支在167个提交后面是"origin/master",可以快速转发.
我试过了:
git checkout HEAD
Run Code Online (Sandbox Code Playgroud)
它没有效果.这是因为我在master上签出了一个中间提交.
如何让主人留在头上?
TreeSet使用相同的Comprator值删除不同的项目.我不希望它被删除.有没有办法控制这个?或者使用另一个容器类?
补充:好的.好像我不能用Set.出于性能考虑,我需要插入排序功能.Can List可以这样做吗?谢谢大家.
例如,我想在代码/命令行中启动gmail,但我不知道它的主要活动名称.
我开始-n com.google.android.gm/.XXXXX
它可以通过反编译apk来实现,但很难.
谢谢.
public class Array
{
static String[] a = new String[] {"red", "green", "blue"};
static Point[] p = new Point[] {new Point(1, 2), "3,4"};
public static void main(String[] args)
{
System.out.println("hello");
}
class Point
{
int x;
int y;
Point(int x, int y)
{
this.x = x;
this.y = y;
}
Point(String s)
{
String[] a = s.split(",");
x = a[0].parseInt();
y = a[1].parseInt();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的程序中,静态Point
数组初始化失败,报告错误:
Array.java:4: non-static variable this cannot be referenced from a static context …
Run Code Online (Sandbox Code Playgroud) 我在我的活动中创建了一个 ListView,另外两个按钮(上一个,下一个)用于在 ListView 上移动一个突出显示。当单击这两个按钮时,我调用 setSelection(pos),但列表视图上没有高亮显示。
我还尝试使用布局文件自定义列表项,并在其上注册选择器,如:http : //android-codes-examples.blogspot.com/2011/03/customized-listview-items-selection.html
不幸的是,它没有按预期工作。当我触摸列表项时,此方法确实更改了颜色,但是当我调用 setSelection() 时没有突出显示。
layout/main.xml(主布局):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="4"
>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="vertical"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="3">
<Button
android:id="@+id/btn_prev"
android:text="prev"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="@+id/btn_next"
android:text="next"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
List.java(活动):
package com.android.list;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TableRow;
import android.widget.SimpleAdapter;
import android.widget.SimpleAdapter.ViewBinder;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.graphics.Point;
import android.graphics.Color; …
Run Code Online (Sandbox Code Playgroud) //src/com/test/animal/Animal.java
package com.test.animal;
public class Animal
{
Animal()
{
init();
}
public void init()
{
System.out.println("parent init()");
}
}
//src/com/test/animal/Dog.java
package com.test.animal;
public class Dog extends Animal
{
String name = null;
Dog()
{
super();
}
public void init()
{
System.out.println("child init()");
super.init();
name = new String("dog");
System.out.println("name: "+name);
}
public static void main(String[] args)
{
Dog d = new Dog();
System.out.println("name: "+d.name);
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
child init()
parent init()
name: dog
name: null
Run Code Online (Sandbox Code Playgroud)
似乎调用了子中的init(),但是没有保存NAME值!为什么?如果我将NAME移动到父级,那就没关系.然而,保留在孩子身上更合理,因为它是特定于狗的.
另外,我可以在child的构造函数中显式调用init()来解决这个问题.这不是那么好.