Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android facebook sdk安卓墙贴换行符_Android_Facebook - Fatal编程技术网

Android facebook sdk安卓墙贴换行符

Android facebook sdk安卓墙贴换行符,android,facebook,Android,Facebook,我正在制作一个应用程序,使用facebook sdk for android将一些信息发布到你的facebook墙上。这是可行的,但我似乎无法在帖子上找到新词。我试过\n,但没用。有什么建议吗 这是我的密码: Bundle parameters = new Bundle(); String temp = ""; for (int i = 0; i < mArrayAdapter.getCount(); i++){ temp = temp + mArrayAdapt

我正在制作一个应用程序,使用facebook sdk for android将一些信息发布到你的facebook墙上。这是可行的,但我似乎无法在帖子上找到新词。我试过
\n
,但没用。有什么建议吗

这是我的密码:

Bundle parameters = new Bundle();

String temp = "";
for (int i = 0; i < mArrayAdapter.getCount(); i++){
            temp = temp + mArrayAdapter.getItem(i) + "\n"; // Not working
}

parameters.putString("message", temp);
mFacebook.dialog(this, "stream.publish", parameters, new DialogListener());  
Bundle参数=新Bundle();
字符串temp=“”;
对于(int i=0;i
谢谢


詹姆斯·福特(James Ford)

嗨,詹姆斯,我以前也试过,即使是用html代码,但我认为这是不可能的。
原因是,Facebook必须有一个控件,以避免其帖子上出现空格或换行。

流式帖子中不允许出现新行(事实上,您过去可能在Facebook上看到过新行是错误的)。

这是有效的:

使用此选项:


代替br或换行符等。你只能一行做一个(即不能增加间距)。

使用JSON在facebook上发布。。 怎么做

步骤:-

步骤1:-在这个链接中,你将了解如何使用JSON将文本设置为TEXTVIEW

第2步:-可能这不是你要找的:)将textview的文本分配给某个字符串 使用
GetText().ToString

第3步:-使用此字符串发布到facebook

第四步:-我花了很多时间在谷歌上搜索后也做了同样的事情,最终得到了结果 通过使用这个技巧。你可以看到我在测试期间发布的帖子

第5步:-使用将此文本框的可见性设置为gone

tv.setVisibility(View.GONE)
你在facebook上的发帖也完成了。。 让facebook和textview处理他们如何管理空格和新行字符:D

一些像我这样的新手的编码工作

我是在点击按钮后发布的

(一)

2) 将单击事件添加到此按钮

   private View.OnClickListener mthdpost=new View.OnClickListener() {

        @Override
        public void onClick(View v) {
try {
                String json = "{"

                    + "  \"name\": \"myName\", "

                    + "  \"message\": [\"myMessage1\",\"myMessage2\"],"

                    + "  \"place\": \"myPlace\", "

                    + "  \"date\": \"thisDate\" "

                    + "}";

                /* Create a JSON object and parse the required values */

                JSONObject object = (JSONObject) new JSONTokener(json).nextValue();

                String name = object.getString("name");

                String place = object.getString("place");

                String date = object.getString("date");

                JSONArray message = object.getJSONArray("message");

                String MessageToPost= null;
                tv.setText("Name: "+ name +"\n\n");

                tv.append("Place: "+ place +"\n\n");

                tv.append("Date: "+ date +"\n\n");



                /*JSONObject attachment = new JSONObject();

                attachment.put("Name: ","\n\n");

                attachment.put("Place: ","\n\n");

                attachment.put("Date: ","\n\n");*/

                for(int i=0;i<message.length();i++)

                {

                    tv.append("Message: "+ message.getString(i) +"\n\n");
                    //attachment.put("Message: ","\n\n");

                }
                MessageToPost=tv.getText().toString();
                postToWall(MessageToPost);// called the method having logic to post on wall and sending the textview text to to post as message

                } catch (JSONException e)
                {e.printStackTrace();
                }

                catch(Exception ex)
                {ex.printStackTrace();}

                }


        };
希望能有所帮助:)这对我来说很有用:

StringBuilder messageData = new StringBuilder(title).append('\n')
    .append('\n').append(message).append('\n').append('\n')
    .append(description);
// Message
postParams.putString("message", messageData.toString());

似乎是真的。但我能做的是在墙上键入时使用alt+enter键生成新行。也许你可以用这个做点什么?这是个诀窍,但是,如上所述,不适合新词。当你说“有诀窍”然后说“不适合新词”是什么意思?它允许你从一行开始(虽然不是连续两行),一个典型的新行字符代码可以重复多次。“中心”标记诱使渲染器结束一行,因为角色对正更改。因此,您可以使用它来终止一行,但这不会导致段落之间出现空行,这在很大程度上是可读文本的要求。。。但它确实产生了一条新的路线;正确的?一行中不得超过一个(即垂直间距)。严格地说,我的答案是有效的。它会断线,是的,所以你可以让文本从另一行开始。我说不出渲染器在做什么,可以吗?在我看来,它基本上混淆了渲染器
public void postToWall(String msg){


        Log.d("Tests", "Testing graph API wall post");
        try {
               String response = facebook.request("me");
               Bundle parameters = new Bundle();
               //parameters.putString("message", msg.toString());
               parameters.putString("message", msg);
               parameters.putString("description", "test test test");
               response = facebook.request("me/feed", parameters, 
                       "POST");
               Log.d("Tests", "got response: " + response);
               if (response == null || response.equals("") || 
                       response.equals("false")) {
                  Log.v("Error", "Blank response");
               }
        } catch(Exception e) {
            e.printStackTrace();
        }

        }
StringBuilder messageData = new StringBuilder(title).append('\n')
    .append('\n').append(message).append('\n').append('\n')
    .append(description);
// Message
postParams.putString("message", messageData.toString());