开发者

How to Put String Variable in Following Code?

How to Put String Variable in following Code, Please Help me.

parameters.putString("attachment","{\"name\":\"Facebook application By Martin\",\"href\":\"http://www.google.com/\",\"caption\":\"By Google Technology \",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\"http://4.bp.blogspot.com/-9RPH9UGDSsE/TcGjy3fAHlI/AAAAAAAAAeI/kuQXLE_G5Ew/s1600/Flag+Wallpaper+of+India+%25283%2529.jpg\",\"href\":\"http://s.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"for more tips cli开发者_如何学Pythonck here\",\"href\":\"http://www.google.com/\"}}}");

I use Above Code for Upload Image on Facebook Wall.But i want to use string variable & pass following path from variable.

http://4.bp.blogspot.com/-9RPH9UGDSsE/TcGjy3fAHlI/AAAAAAAAAeI/kuQXLE_G5Ew/s1600/Flag+Wallpaper+of+India+%25283%2529.jpg

Thanks in Advance.


I suggest you to refer this link: String Resources in Android.

Now Just check this example in the given link:

Define the below string inside the strings.xml:

<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>

Now from activity class, you can get string and pass parameter value as:

Resources res = getResources();
String text = String.format(res.getString(R.string.welcome_messages), username, mailCount);

So this is the basic example for your reference.

You can also define your string value inside the strings.xml and pass the parameter as per your requirement.


String myPath = "http://4.bp.blogspot.com/-9RPH9UGDSsE/TcGjy3fAHlI/AAAAAAAAAeI/kuQXLE_G5Ew/s1600/Flag+Wallpaper+of+India+%25283%2529.jpg";

String myUrl = "parameters.putString("attachment","{\"name\":\"Facebook application By Dipak Keshariya\",\"href\":\"http://www.arthisoft.com/\",\"caption\":\"By Google Technology \",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\" + myPath + \",\"href\":\"http://s.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"for more tips click here\",\"href\":\"http://www.google.com/\"}}}");
";

Look at how I have changed the url in your call by using the concatenation operator ' + myPath + '

This is very, very basic. You should start learning java if you want to become an Android developer.

On another note, on your picture, top left corner, are you really sure you are a "PROUND" indian ?? :D

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜