如何超过65535字节的限制方法code [英] How to exceed 65535 byte limit for method code

查看:300
本文介绍了如何超过65535字节的限制方法code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个产品列表,但Java的抱怨,该方法超过65535字节的限制。我怎么可以添加更多的单词和克服限制?

I have a product list but Java complains that the method exceeds the limit of 65535 bytes. How can I add more words and overcome the limit?

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
        }
    });


}

}

有关更容易理解:

在此先感谢

推荐答案

这是不是限制做sqlite的,据我可以告诉 - Eclipse的错误显示,这是一个问题的方法

This isn't a limitation to do with Sqlite as far as I can tell - the Eclipse error is showing that it's a problem with the method.

我会的强烈的建议,如果你有大量的数据,你应该保持在一个单独的资源。然后,只需加载在执行时的资源。有没有必要把它烤到您的 code 的。你总是可以包括一些字符串替换与平台的行分隔符,如果你需要。

I would strongly suggest that if you have a lot of data, you should keep that in a separate resource. Then just load the resource at execution time. There's no need to have it baked into your code. You can always include some string to replace with the platform line separator if you need to.

这篇关于如何超过65535字节的限制方法code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆