成都网站建设公司哪家好一些?
本人是成都的,想找一个做网站做的比较好的成都网站建设公司,大家推荐吗?
更新时间:2022-08-10 16:08
最满意答案
您必须先在某处初始化ArrayList实例,然后才能像这样实际添加值
public ArrayList<TextView> Durations = new ArrayList<TextView>(); public ArrayList<Long> periods = new ArrayList<Long>();
直接来自文档,
什么时候抛出NullPointerException?
当应用程序在需要对象的情况下尝试使用null时抛出。 这些包括:
- 调用null对象的实例方法。
- 访问或修改空对象的字段。 将null的长度视为数组。
- 访问或修改null的插槽,就像它是一个数组一样。
- 抛出null,好像它是一个Throwable值。
You have to initialize the ArrayList instances somewhere before you can actually add values to it like this
public ArrayList<TextView> Durations = new ArrayList<TextView>(); public ArrayList<Long> periods = new ArrayList<Long>();
Directly from the documentation,
When NullPointerException is thrown?
Thrown when an application attempts to use null in a case where an object is required. These include:
- Calling the instance method of a null object.
- Accessing or modifying the field of a null object. Taking the length of null as if it were an array.
- Accessing or modifying the slots of null as if it were an array.
- Throwing null as if it were a Throwable value.
相关问答
更多-
无法设置ArrayList
(ArrayList [2023-04-13]cannot be set) 您必须先在某处初始化ArrayList实例,然后才能像这样实际添加值 public ArrayListDurations = new ArrayList (); public ArrayList periods = new ArrayList (); 直接来自文档, 什么时候抛出NullPointerException? 当应用程序在需要对象的情况下尝试使用null时抛出。 这些包括: 调用null对象的实例方法。 访问或修改空对象的字段。 将 ... -
尝试 span.setSpan(new RelativeSizeSpan(0.8f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Try span.setSpan(new RelativeSizeSpan(0.8f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-
使用TextUtils.isEmpty if(TextUtils.isEmpty(data.getName())){ viewHolder.mName.setVisibility(GONE); }else{ viewHolder.mName.setVisibility(VISIBLE); } if(TextUtils.isEmpty(data.getNameTwo())){ viewHolder. mNameTwo.setVisibility(GONE); }else{ viewHolder.mNa ...
-
Android - 如何将ArrayList的值设置为TextView(Android - How to set value of ArrayList to TextView)[2024-01-26]
你可以这样做; 直接在for循环中使用pathName ... desk.setText(""); for (int j = 0; j < pathName.size(); j++){ desk.append("Deskripsi:\n" + pathName.get(j) + "\n"); } You can do this instead; use pathName directly in the for loop... desk.setText(""); for (int j = 0; j ... -
Arraylist TextView(Arraylist TextView)[2022-07-18]
缺少textView.setText("SomeText") 你应该做这个 yourTextView.setText(textItem.getDescription) 你也在循环中为同一个textview分配了很多值,这是错误的,你会有一个textItems显示 码 import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle; public class ... -
请使用Context of activity作为ArrayAdapter的第一个参数,您可以使用 ActivityName.this而不是this ,其中ActivityName是活动类的名称。 看来你正在运行这个代码,在一些Runnable或Thread类中,所以现在, this是一个Runnable对象的实例。 Please use Context of activity as the first parameter of the ArrayAdapter, you can use ActivityNa ...
-
不要混淆。 List
> outerlist = new ArrayList >(outCapacity); 和 ArrayList innerList= new ArrayList (InnCapacity); // adding some elements to innerlist as well. 现在 outerList.add(innerList); 所以你只是增加了outerlist和inn ... -
将文本设置为textView(Set text to a textView)[2021-06-27]
实际上你需要添加一个布局(视图),其中textView1将在那里例如试试这个: setContentView(R.layout.x1); 所以你的代码就是这样 public class settext extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.x1); TextV ... -
TextView Scrollable(TextView Scrollable)[2023-12-03]
你为什么不在xml中使用ScrollView将更容易打开ScrollView打开一个布局设置它你想要它是如何水平或垂直放入你的TextViews然后先关闭布局然后ScrollView和Voila完成.. What I did to solve my problem: textView.post(new Runnable() { @Override public void run() { textHeight = textViews.getLi ... -
尝试这样的事情......你可以摆脱Arraylists。 记住一个字符串基本上是一个字符数组。 创建一个实现runnable的自定义文本视图,以便在主线程上完成您尝试对文本执行的工作。 package com.example.stackquestion; import java.util.ArrayList; import android.content.Context; import android.graphics.Color; import android.os.SystemClock; imp ...