gpt4 book ai didi

android - 如何超过方法代码的 65535 字节限制

转载 作者:IT王子 更新时间:2023-10-29 06:27:46 27 4
gpt4 key购买 nike

我有一个产品列表,但 Java 提示该方法超出了 65535 字节的限制。如何添加更多字数并克服限制?

public class ProductList extends Activity {

// List view
private ListView lv;

// Listview Adapter
ArrayAdapter<String> adapter;

// Search EditText
EditText inputSearch;

// ArrayList for Listview
ArrayList<HashMap<String, String>> productList;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product_list);


String as = System.getProperty("line.separator");

String products[] = {


// I want these words to keep in a database
// Because here is 65kb limit but I need more...



"Banana" +as+ "Its color is yellow." ,
"Orange" +as+ "Orange is a sour fruit." ,
"Onion" +as+ "Onion usually used on Pizza" ,
"Google" +as+ "Google is a giant search engine." ,
"Love" +as+ "Love is related to heart." ,
"Lily" +as+ "It is one kind of white flower." ,
"Banana" +as+ "Its color is yellow." ,
"Orange" +as+ "Orange is a sour fruit." ,
"Onion" +as+ "Onion usually used on Pizza" ,
"Google" +as+ "Google is a giant search engine." ,
"Love" +as+ "Love is related to heart." ,
"Lily" +as+ "It is one kind of white flower." ,
"Banana" +as+ "Its color is yellow." ,
"Orange" +as+ "Orange is a sour fruit." ,
"Onion" +as+ "Onion usually used on Pizza" ,
"Google" +as+ "Google is a giant search engine." ,







};



lv = (ListView) findViewById(R.id.list_view);
inputSearch = (EditText) findViewById(R.id.inputSearch);

// Adding items to listview
adapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.p_list, products);
lv.setAdapter(adapter);

/**
* Enabling Search Filter
* */
inputSearch.addTextChangedListener(new TextWatcher() {

@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
ProductList.this.adapter.getFilter().filter(cs);
}

@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub

}

@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});


}

}

为了更容易理解:

enter image description here

提前致谢

最佳答案

据我所知,这不是对 Sqlite 的限制 - Eclipse 错误表明这是方法的问题。

强烈建议,如果您有大量数据,则应将其保存在单独的资源中。然后只需在执行时加载资源。无需将其融入您的代码。如果需要,您始终可以包含一些字符串以替换为平台行分隔符。

关于android - 如何超过方法代码的 65535 字节限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13846340/

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