gpt4 book ai didi

android - 错误获取字符串到数组字符串和字符串到数组 int

转载 作者:行者123 更新时间:2023-11-30 01:31:35 25 4
gpt4 key购买 nike

我试图通过按下应用程序按钮并在将整数转换为字符串时在编辑文本中写入类似 1 + 1 的内容,以便将它们放在其余的整数旁边,例如:11 而不是 1+1 (=2 )我在这行代码中收到错误“FATAL EXCEPTION”当按下任何数字按钮时

N[ii] = Integer.parseInt(stringNumber);

在按下 Sins x、+、- 按钮时,显示计算方法中也出现错误“致命异常”

private void insertOrCheckNumber() {
if (End == 0) {
ii++;
} else if (u == 0) {
N = new int[ii];
stringNumber = stringNumber + String.valueOf(num);
displayCalculations(stringNumber);
N[ii] = Integer.parseInt(stringNumber);
}
if (u == 1) {
Sins = new String[iii];
displayCalculations(Sins[iii]);
}

}
private void clickNumber(int cN) {
u = 0;
num = cN;
insertOrCheckNumber();
}

private void displayCalculations(String txt) {
Calcs = String.valueOf(showCalcs.getText());
showCalcs.setText(Calcs + " " + txt);
}

最佳答案

在您的 Activity 中

私有(private)ListView ListView ;

onCreate

listView = (ListView) findViewById(R.id.listView);  
ArrayList<> finalN = new ArrayList<y>;
customAdapter = new listAdapter(this,R.layout.listview_example, finalN);
listView.setAdapter(customAdapter);

public class listAdapter extends ArrayAdapter<>
{
public listAdapter(Context context, int resource, List<> objects) {
super(context, resource, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();

View v = convertView;
if (v == null) {
LayoutInflater vi;
vi = LayoutInflater.from(getContext());
v = vi.inflate(R.layout.listview_example, null);
}
//Setting the value to the textfields
return v;
}

如果您想要我的完整代码,请询问,我会发送给您 ;)

关于android - 错误获取字符串到数组字符串和字符串到数组 int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35689822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com