小编Bax*_*tex的帖子

Android Studio和Github缺少.iml文件

我正在使用Android Studio版本1.5.1,克隆和使用Github时遇到问题.在我的gitignore文件中,我得到一个文字说*.iml,据我所知这意味着我的所有iml文件都被git忽略而没有上传.当我的项目协作者克隆我的项目时,他们会收到一条错误消息,告诉他们有2个丢失的iml文件.要求他们保留或删除它们.无论它们做什么都没关系,它仍然会给出同样的问题.他们无法编码或构建任何东西.

据我所知,iml文件不应该上传到github,而是Android Studio在构建或导入项目时应自动生成它们.

我们做错了什么?

git android

8
推荐指数
1
解决办法
4250
查看次数

迭代Arraylist <String []>

我有一个ArrayList完整的String数组,我无法弄清楚如何循环.迭代器对我来说是新的,即使我过去使用它们,我也不知道该怎么做.

Iterator<String[]> iterator = list.iterator();
                while (iterator.hasNext()) {
                    String trip = "Till: " + iterator.next(0) + " | Från: " + list.get(4) + " | Kostar: " + list.get(1) +"kr | Avgår: " + list.get(2) + " | Ankomst Tid: " + list.get(3) + " | Antal bokningar: " + list.get(4);
Run Code Online (Sandbox Code Playgroud)

这是我正在做的一些实验.我虽然iterator.next()会在当前行返回StringArray,所以我尝试了例如iterator.next(0).据我所知list.get(x)只给我一行.

在上面的代码中,我希望每个行String Array都在某个索引处.像这样的东西:

for each row
 system.out.println(String[2] +String[5]);
Run Code Online (Sandbox Code Playgroud)

java arrays iterator arraylist

6
推荐指数
1
解决办法
2万
查看次数

Dockerfile 高山图像 apk 找不到 Java 8

我想减少我的 docker 镜像并切换到 alpine 基础镜像。这会导致 bash 找不到 apt 的问题。事实证明,我必须改用 apk。但是,它似乎没有找到我需要的 java 版本。这是我的 dockerfile

#Use alpine golang
FROM golang:alpine

#Get the code from local code commit repo
WORKDIR /go/src/xxx
COPY . /go/src/xxx

#Install Java and cleanup after in the same layer
RUN apk update && apk add openjdk-8-jre-headless && rm -rf /var/lib/apt/lists/*

#Install dependencies recursively and remove the third_party directory after it has been used for compiling.
RUN go get ./... && go run setup.go && RUN rm -rf third_party
#More …
Run Code Online (Sandbox Code Playgroud)

docker alpine-linux alpine-package-keeper

6
推荐指数
2
解决办法
2万
查看次数

获得月份为 01,02 而不是 1,2

我正在使用日历类,更具体地说,我需要将所有 12 个月作为两个数字返回。

如果我使用以下代码:

 int month = (myCalendar.get(Calendar.MONTH)) +1;
Run Code Online (Sandbox Code Playgroud)

这是我在不同月份得到的结果:1、2、3、4、5、6、7、8、9、10、11、12

但我真正需要的是:01,02,03,04,05,06,07,08,09,10,11,12

这是因为我需要制作子字符串,如果我得到的整数数量会出错。有没有简单的方法来解决这个问题?

我可以使用 if 语句并检查整个日期是否只有 5 个数字,然后添加 0 和 3 位置,但感觉很麻烦。

java android calendar

5
推荐指数
2
解决办法
6672
查看次数

如何将字符串转换为int或decimal?

我有这个代码:

Console.WriteLine("What is the price of the product?"); 
Decimal price = Decimal.Parse(Console.ReadLine());  
Run Code Online (Sandbox Code Playgroud)

我将输入作为字符串作为int或/和十进制数并将其转换为变量.或者,这是我的意图.输入是产品的价格,它可以有小数,也可以不是.我只输入整数,它可以工作,但是小数点会崩溃.我是新手,我似乎无法找到答案.

c# decimal

2
推荐指数
1
解决办法
1611
查看次数

需要可转换为“int”类型的对象

这是我的代码:

\n\n
namespace Cinemaseats\n\n {public partial class MainForm : Form\n    {\n    private const int numOfSeats = 60;\n    private int numOfReservedSeats = 0;\n    Seat currentSeat = new Seat();\n    public MainForm()\n    {\n        InitializeComponent();\n        InitializeGUI();\n    }\n\n    private void InitializeGUI()\n    {\n        radioButton1.Checked = true;\n        namn.Text = string.Empty;\n        pris.Text = string.Empty;\n    }\n    private void button1_Click(object sender, EventArgs e)\n    {\n        **int seatNr = ReadAndValidateSeatNr();**\n\n        if (seatNr < 0)\n        {\n            MessageBox.Show("V\xc3\xa4lj ett f\xc3\xb6rem\xc3\xa5l fr\xc3\xa5n listan");\n            return;\n        }\n\n        if (radioButton2.Checked)\n            ReserveSeat(seatNr);\n        else\n            CancelSeat(seatNr);\n\n        UpdateGUI(seatNr);\n    }\n\n    public int GetnumOfSeats()\n …
Run Code Online (Sandbox Code Playgroud)

c# string int implicit-conversion

0
推荐指数
1
解决办法
1万
查看次数

尝试使用if语句捕获块

所以我在程序中实现try catch块时遇到了一些问题.这很简单,我想要的只是当用户在对话框窗口输入0或更少时抛出异常.这是我的代码:

try {
    if (this.sides <= 0);
} catch (NegativeSidesException exception) {
    System.out.println(exception + "You entered 0 or less");
}
Run Code Online (Sandbox Code Playgroud)

NegativeSidesException是我自己定义的异常.

当我输入0时,try catch块没有捕获它,编译器抛出一个正常的异常并终止程序

java try-catch

0
推荐指数
3
解决办法
4万
查看次数

Java CompareTo方法声明我无法将int转换为boolean,即使它们都没有使用

public int compareTo(Person p) {
    int res = 1;
    String personStr = p.getId();
    String thisId = this.getId();

    if(thisId.equals(personStr)){
        res = 0;
    }
    else if(thisId.compareTo(personStr)){
        res = -1;
    }

    return res;
}
Run Code Online (Sandbox Code Playgroud)

我已经实现了一个非常简单的compareTo方法,但是我没有收到错误消息.如果statemint中的条件给我一条消息,说它不能从int转换为boolean.我明白了,但问题是我正在使用netiher.我只是想比较两个简单的字符串,为什么会这样呢?

java interface compareto comparable

0
推荐指数
1
解决办法
811
查看次数

Android studio app随机耗尽内存

我正在构建一个小应用程序,昨天工作得很好,但今天添加按钮后没有.我恢复了所有的更改,但我仍然得到相同的错误,即应用程序内存不足.这是代码和堆栈跟踪:

public class MainActivity extends AppCompatActivity {
private MainActivity mainActivity = new MainActivity();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent …
Run Code Online (Sandbox Code Playgroud)

java android

0
推荐指数
1
解决办法
62
查看次数