- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 3 个 textViews 我正在尝试使用 JSON 填充 - 我能够将数据放入 textViews 但由于某种原因我得到不正确的数据(我正在尝试使用名称、内容的值并在 JSON 响应中发布下面。)我还注意到,当我应该有一个独特的评论列表时,相同的数据会一遍又一遍地重复。我不确定我到底做错了什么,但任何建议都值得赞赏。
java :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player);
String title = getIntent().getStringExtra("title");
String uploader = getIntent().getStringExtra("uploader");
String viewCount = getIntent().getStringExtra("viewCount");
TextView titleTv = (TextView) findViewById(R.id.titleTv);
TextView uploaderTv = (TextView) findViewById(R.id.uploaderTv);
TextView viewCountTv = (TextView) findViewById(R.id.viewCountTv);
titleTv.setText(title);
uploaderTv.setText("by" + uploader + " |");
viewCountTv.setText(viewCount + " views");
YouTubePlayerView youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubeplayerview);
youTubePlayerView.initialize(API_KEY, this);
ListView lv = (ListView) findViewById(R.id.list);
CustomAdapter cus = new CustomAdapter(Player.this, list);
lv.setAdapter(cus);
Handler handler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
return false;
}
});
GetYouTubeUserCommentsTask task = new GetYouTubeUserCommentsTask(
handler, viewCount);
task.execute();
}
@Override
public void onInitializationFailure(Provider provider,
YouTubeInitializationResult result) {
Toast.makeText(getApplicationContext(), "onInitializationFailure()",
Toast.LENGTH_LONG).show();
}
@Override
public void onInitializationSuccess(Provider provider,
YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
String video_id = getIntent().getStringExtra("id");
player.loadVideo(video_id);
}
}
public final class GetYouTubeUserCommentsTask extends
AsyncTask<Void, Void, Void> {
public static final String LIBRARY = "CommentsLibrary";
private final Handler replyTo;
private final String username;
String video_id = getIntent().getStringExtra("id");
public GetYouTubeUserCommentsTask(Handler replyTo, String username) {
this.replyTo = replyTo;
this.username = username;
}
@Override
protected Void doInBackground(Void... arg0) {
try {
HttpClient client = new DefaultHttpClient();
HttpUriRequest request = new HttpGet(
"http://gdata.youtube.com/feeds/api/videos/"
+ video_id
+ "/comments?v=2&alt=json&start-index=1&max-results=50&prettyprint=true");
HttpResponse response = client.execute(request);
String jsonString = StreamUtils.convertToString(response
.getEntity().getContent());
JSONObject json = new JSONObject(jsonString);
JSONArray jsonArray = json.getJSONObject("feed").getJSONArray(
"entry");
List<Comments> comments = new ArrayList<Comments>();
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String name = jsonObject.optString("name", "defaultValue");
String content = jsonObject.optString("content",
"defaultValue");
String published = jsonObject.optString("published",
"defaultValue");
list.add(new CommentsLibrary(name, content, published));
}
} catch (ClientProtocolException e) {
Log.e("Feck", e);
} catch (IOException e) {
Log.e("Feck", e);
} catch (JSONException e) {
Log.e("Feck", e);
}
return null;
}
@Override
protected void onPostExecute(Void result) {
}
}
public class CustomAdapter extends BaseAdapter {
LayoutInflater mInflater;
ArrayList<CommentsLibrary> list;
public CustomAdapter(Context context, ArrayList<CommentsLibrary> list) {
mInflater = LayoutInflater.from(context);
this.list = list;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item, parent,
false);
holder = new ViewHolder();
holder.tv1 = (TextView) convertView
.findViewById(R.id.textView1);
holder.tv2 = (TextView) convertView
.findViewById(R.id.textView2);
holder.tv3 = (TextView) convertView
.findViewById(R.id.textView3);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tv1.setText(list.get(position).getName());
holder.tv2.setText(list.get(position).getContent());
holder.tv3.setText(list.get(position).getPublished());
return convertView;
}
class ViewHolder {
TextView tv1, tv2, tv3;
}
}
}
{"encoding":"UTF-8","feed":{"logo":{"$t":"http:\/\/www.gstatic.com\/youtube\/img\/logo.png"},"link":[{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments?v=2","rel":"http:\/\/schemas.google.com\/g\/2005#feed"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments\/batch?v=2","rel":"http:\/\/schemas.google.com\/g\/2005#batch"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments?alt=json&max-results=50&v=2","rel":"self"},{"type":"application\/atomsvc+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments?alt=atom-service&v=2","rel":"service"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments?alt=json&alt=json&start-token=Gq4ECqsECDISpgQACgAAAEQSAQAgAAgAEAIAgQALIAIAACFAAAAAAACQMCGAYQAkgASQACEAAgEAAAAQAHAAAQQAoQCYAIFGAEAIKgMgBAASASACAAgAAAABBAAKIAAAAJgMIAjARIAAAAUAAAAIAhCDMggSCAQAAAIIAAQEiAAgBAAQQEIIEAAEAACBgShAAiAAAAgAAAIAgQAgAYXEAiMAAgACAAAQAACAQAAQACCAAQQASAQQAAgAAEREAAAAAYABQSAAAABAQAAAhAAKBBAgQAAAACIAAAIECBMCgQBMAAACEEAQAIBAAIQgAIgAJgAAEJgAAgBAABIBCIAAAAgEASABAAIAAAAiAgCAgAAIABgEACEEAAgIAAgAQAAAAAACAAVAWIAQkAiBwAAAJAASACgCAAAECEASBIwwAEAAQhBAADAAAAAAAABAABAxYAACACAhAAEEgAAgQAABAABAARAgISAAAgAAAgYCEAAAYjAAIEABGQEAAABAAAAUAAAAggAAIAELACAJEIAAAABAEEAAg4AEUgABAAggShAADAABASADAAAAACgZRACAAAAEAAAIAAoQCHALIgEAAAAKAAAAAC4AAABAQAAAAAQAQAAAAiAAAAAABBRABAABFEMAQAAEAAIIQABMhAQQAAAYgABCAAIgABAAAMACAAYYIAggABIEBACEoAAIEAEABAEAAAsIQEAAAAAgAAAEEAAAAKFAgAQECAgAASkARhARKJzIiNL4gLsCMJScl6aUtbsCOAFAAQ%3D%3D&max-results=50&v=2","rel":"next"}],"openSearch$totalResults":{"$t":664},"xmlns":"http:\/\/www.w3.org\/2005\/Atom","id":{"$t":"tag:youtube.com,2008:video:AaWp8YZi1Ns:comments"},"author":[{"uri":{"$t":"http:\/\/www.youtube.com\/"},"name":{"$t":"YouTube"}}],"xmlns$openSearch":"http:\/\/a9.com\/-\/spec\/opensearch\/1.1\/","category":[{"scheme":"http:\/\/schemas.google.com\/g\/2005#kind","term":"http:\/\/gdata.youtube.com\/schemas\/2007#comment"}],"xmlns$gd":"http:\/\/schemas.google.com\/g\/2005","updated":{"$t":"2013-12-16T16:26:06.146Z"},"xmlns$yt":"http:\/\/gdata.youtube.com\/schemas\/2007","gd$etag":"W\/\"C0YCR38_fip7I2A9Wh5UEkw.\"","entry":[{"yt$videoid":{"$t":"AaWp8YZi1Ns"},"content":{"$t":"He was doin his shit before Logic though. I don't think either of them know \neach other. Wax is a lot older."},"id":{"$t":"tag:youtube.com,2008:video:AaWp8YZi1Ns:comment:z13eg1lpnsbjffkvh23bczqysty3dld0f"},"yt$googlePlusUserId":{"$t":"108900457503123436988"},"author":[{"yt$userId":{"$t":"CHSZNY4x6F6pWRJobUoFYQ"},"uri":{"$t":"http:\/\/gdata.youtube.com\/feeds\/api\/users\/CHSZNY4x6F6pWRJobUoFYQ"},"name":{"$t":"Aaron Tucci"}}],"title":{"$t":"He was doin his ..."},"category":[{"scheme":"http:\/\/schemas.google.com\/g\/2005#kind","term":"http:\/\/gdata.youtube.com\/schemas\/2007#comment"}],"updated":{"$t":"2013-11-20T17:14:52.000Z"},"gd$etag":"W\/\"DUENQ347eCp7I2A9Wh5XGUs.\"","link":[{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns?v=2","rel":"related"},{"type":"text\/html","href":"http:\/\/www.youtube.com\/watch?v=AaWp8YZi1Ns","rel":"alternate"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments\/z13eg1lpnsbjffkvh23bczqysty3dld0f?v=2","rel":"self"}],"published":{"$t":"2013-11-20T17:14:52.000Z"},"yt$channelId":{"$t":"UCCHSZNY4x6F6pWRJobUoFYQ"},"yt$replyCount":{"$t":0}},{"yt$videoid":{"$t":"AaWp8YZi1Ns"},"content":{"$t":"This will play at my funeral"},"id":{"$t":"tag:youtube.com,2008:video:AaWp8YZi1Ns:comment:z12qdzqpvtzzgb3wn04cefsy5yfbtpwgfr40k"},"yt$googlePlusUserId":{"$t":"114722569313545191091"},"author":[{"yt$userId":{"$t":"SSYvgm-__QWJ-QBn7WBCOA"},"uri":{"$t":"http:\/\/gdata.youtube.com\/feeds\/api\/users\/EvincentDavis73"},"name":{"$t":"EvincentDavis73"}}],"title":{"$t":"This will play at ..."},"category":[{"scheme":"http:\/\/schemas.google.com\/g\/2005#kind","term":"http:\/\/gdata.youtube.com\/schemas\/2007#comment"}],"updated":{"$t":"2013-11-25T22:03:55.000Z"},"gd$etag":"W\/\"DUcHRH47eCp7I2A9Wh5WFEw.\"","link":[{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns?v=2","rel":"related"},{"type":"text\/html","href":"http:\/\/www.youtube.com\/watch?v=AaWp8YZi1Ns","rel":"alternate"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments\/z12qdzqpvtzzgb3wn04cefsy5yfbtpwgfr40k?v=2","rel":"self"}],"published":{"$t":"2013-11-25T22:03:55.000Z"},"yt$channelId":{"$t":"UCSSYvgm-__QWJ-QBn7WBCOA"},"yt$replyCount":{"$t":0}},{"yt$videoid":{"$t":"AaWp8YZi1Ns"},"content":{"$t":"Damn Wax, will always be chill"},"id":{"$t":"tag:youtube.com,2008:video:AaWp8YZi1Ns:comment:ENZPbF_dkcQPL32E3PWUkDO2TriUzzdwwutHskE4KyI"},"author":[{"yt$userId":{"$t":"HvHwTN1oQo8ReLJizlGeTA"},"uri":{"$t":"http:\/\/gdata.youtube.com\/feeds\/api\/users\/HvHwTN1oQo8ReLJizlGeTA"},"name":{"$t":"Mark Henry Salvador"}}],"title":{"$t":"Damn Wax, will ..."},"category":[{"scheme":"http:\/\/schemas.google.com\/g\/2005#kind","term":"http:\/\/gdata.youtube.com\/schemas\/2007#comment"}],"updated":{"$t":"2013-10-22T17:57:38.000Z"},"gd$etag":"W\/\"DkEBSX47eCp7I2A9Wh5RFEs.\"","link":[{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns?v=2","rel":"related"},{"type":"text\/html","href":"http:\/\/www.youtube.com\/watch?v=AaWp8YZi1Ns","rel":"alternate"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments\/ENZPbF_dkcQPL32E3PWUkDO2TriUzzdwwutHskE4KyI?v=2","rel":"self"}],"published":{"$t":"2013-10-22T17:57:38.000Z"},"yt$channelId":{"$t":"UCHvHwTN1oQo8ReLJizlGeTA"},"yt$replyCount":{"$t":0}},{"yt$videoid":{"$t":"AaWp8YZi1Ns"},"content":{"$t":"Chill song"},"id":{"$t":"tag:youtube.com,2008:video:AaWp8YZi1Ns:comment:ENZPbF_dkcS4GpS8ZITWuVUsUYNyrGQGWajSGKIXO38"},"author":[{"yt$userId":{"$t":"hXnILfiYMX0Li4Ok99RDVQ"},"uri":{"$t":"http:\/\/gdata.youtube.com\/feeds\/api\/users\/hXnILfiYMX0Li4Ok99RDVQ"},"name":{"$t":"thedudesons55xD"}}],"title":{"$t":"Chill song"},"category":[{"scheme":"http:\/\/schemas.google.com\/g\/2005#kind","term":"http:\/\/gdata.youtube.com\/schemas\/2007#comment"}],"updated":{"$t":"2013-10-18T17:38:09.000Z"},"gd$etag":"W\/\"DU8MSH47eCp7I2A9Wh5REUw.\"","link":[{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns?v=2","rel":"related"},{"type":"text\/html","href":"http:\/\/www.youtube.com\/watch?v=AaWp8YZi1Ns","rel":"alternate"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments\/ENZPbF_dkcS4GpS8ZITWuVUsUYNyrGQGWajSGKIXO38?v=2","rel":"self"}],"published":{"$t":"2013-10-18T17:38:09.000Z"},"yt$channelId":{"$t":"UChXnILfiYMX0Li4Ok99RDVQ"},"yt$replyCount":{"$t":0}},{"yt$videoid":{"$t":"AaWp8YZi1Ns"},"content":{"$t":"Jammed to this song at the Lancaster show, just fuckin great."},"id":{"$t":"tag:youtube.com,2008:video:AaWp8YZi1Ns:comment:ENZPbF_dkcRbJyAUdl6-zrqjvoZsxzicrhGx2ZovIaI"},"author":[{"yt$userId":{"$t":"-EhhQyun4YBw_LvMZXwXRg"},"uri":{"$t":"http:\/\/gdata.youtube.com\/feeds\/api\/users\/-EhhQyun4YBw_LvMZXwXRg"},"name":{"$t":"RadiationDubstep"}}],"title":{"$t":"Jammed to this song ..."},"category":[{"scheme":"http:\/\/schemas.google.com\/g\/2005#kind","term":"http:\/\/gdata.youtube.com\/schemas\/2007#comment"}],"updated":{"$t":"2013-10-17T19:32:12.000Z"},"gd$etag":"W\/\"AkQHQ347eCp7I2A9Wh5REE4.\"","link":[{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns?v=2","rel":"related"},{"type":"text\/html","href":"http:\/\/www.youtube.com\/watch?v=AaWp8YZi1Ns","rel":"alternate"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments\/ENZPbF_dkcRbJyAUdl6-zrqjvoZsxzicrhGx2ZovIaI?v=2","rel":"self"}],"published":{"$t":"2013-10-17T19:32:12.000Z"},"yt$channelId":{"$t":"UC-EhhQyun4YBw_LvMZXwXRg"},"yt$replyCount":{"$t":0}},{"yt$videoid":{"$t":"AaWp8YZi1Ns"},"content":{"$t":"he sounds like logic"},"id":{"$t":"tag:youtube.com,2008:video:AaWp8YZi1Ns:comment:ENZPbF_dkcSsgrj7dLTiPt_IbMf0WCv3vPaBnNorDEE"},"author":[{"yt$userId":{"$t":"IVTqw7FaRUFdTgK6-XCJsg"},"uri":{"$t":"http:\/\/gdata.youtube.com\/feeds\/api\/users\/IVTqw7FaRUFdTgK6-XCJsg"},"name":{"$t":"Johnny Trikhin"}}],"title":{"$t":"he sounds like logic"},"category":[{"scheme":"http:\/\/schemas.google.com\/g\/2005#kind","term":"http:\/\/gdata.youtube.com\/schemas\/2007#comment"}],"updated":{"$t":"2013-10-17T03:06:36.000Z"},"gd$etag":"W\/\"A0YNR347eCp7I2A9Wh5SGUo.\"","link":[{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns?v=2","rel":"related"},{"type":"text\/html","href":"http:\/\/www.youtube.com\/watch?v=AaWp8YZi1Ns","rel":"alternate"},{"type":"application\/atom+xml","href":"http:\/\/gdata.youtube.com\/feeds\/api\/videos\/AaWp8YZi1Ns\/comments\/ENZPbF_dkcSsgrj7dLTiPt_IbMf0WCv3vPaBnNorDEE?v=2","rel":"self"}],"published":{"$t":"2013-10-17T03:06:36.000Z"},"yt$channelId":{"$t":"UCIVTqw7FaRUFdTgK6-XCJsg"},"yt$replyCount":{"$t":0}},{"yt$videoid":{"$t":"AaWp8YZi1Ns"},"content":{"$t":"Hats off to Wax AND EOM, people don't give E enough credit"},"id":{"$t":"tag:youtube.com,2008:video:AaWp8YZi1Ns:comment:ENZPbF_dkcT6kdus1Qc0wE8XcjPxgFjuZ26nZfV8EQM"},"author":[{"yt$userId":{"$t":"tmYlMT3VSyjLOt6KXeTJjg"},"uri":{"$t":"http:\/\/gdata.youtube.com\/feeds\/api\/users\/tmYlMT3VSyjLOt6KXeTJjg"},"name":{"$t":"PZMCWEequalsMC3"}}],"title":{"$t":"Hats off to Wax AND ..."},"category":[{"scheme":"http:\/\/schemas.google.com\/g\/2005#kind","term":"http:\/\/gdata.youtube.com\/schemas\/2007#comment"}],"updated":{"$t":"2013-10-08T04:31:11.000Z"},"gd$etag":"W\/\"DEEDQH47eCp7I2A9Wh5SEk0.\"","link":[{"type":"application\/atom+xml","href":"http:\/\/gdata.you...
最佳答案
更改此行,您没有更新正确的信息列表
list.add(new CommentsLibrary(name, content, published));
ArrayList
预计
Comments
因此,请在下面进行此更改以实例化
Comments
目的。
comments.add(new CommentsLibrary(name, content, published));
comments.add(new Comments(name, content, published));
CommentsLibrary
实际上是您想要的然后更改您的 ArrayList 和适配器以接受此类型。
list
不是您想要添加项目的对象。并且您想将它们添加到评论 ArrayList
comments
数组列表也是
CustomAdapter cus = new CustomAdapter(Player.this, comments);
setName(name);
setContent(content);
setPublished(published);
确保您实际上是在
CommentsLibrary.java
中的构造函数中调用这些
parsing
JSON
数据错误。我为您修复了解析逻辑,您可能可以将此代码复制并粘贴到您的
doInBackground()
中。方法。
@Override
protected Void doInBackground(Void... arg0) {
DefaultHttpClient client = null;
HttpGet getMethod = null;
HttpResponse response = null;
HttpEntity entity = null;
URI requestUri = null;
try {
client = new DefaultHttpClient();
requestUri = new URI("http://gdata.youtube.com/feeds/api/videos/"
+ video_id
+ "/comments?v=2&alt=json&start-index=1&max-results=50&prettyprint=true");
getMethod = new HttpGet(requestUri);
response = client.execute(getMethod);
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
entity = response.getEntity();
String jsonString = EntityUtils.toString(entity);
JSONObject json = new JSONObject(jsonString);
// Get the Feed From the JSON Response
JSONObject feeds = json.getJSONObject("feed");
JSONArray entryArray = feeds.getJSONArray("entry");
for(int i = 0; i < entryArray.length(); i++){
// Get the entry at index 0
JSONObject entry = entryArray.getJSONObject(i);
// Get the Published data
JSONObject publishedObject = entry.getJSONObject("published");
published = publishedObject.getString("$t");
// Get the Content of the Comment
JSONObject contentObject = entry.getJSONObject("content");
content = contentObject.getString($t);
// Get the Author of the content
JSONArray commentNames = entry.getJSONArray("author");
for(int j = 0; j < commentNames.length(); j++){
// Get the Author Object at the first index
JSONObject singleAuthor = commentNames.getJSONObject(j);
JSONObject authorName = singleAuthor.getJSONObject("name");
name = authorName.getString("$t");
}
comments.add(new CommentsLibrary(name, content, published));
}
}
}catch (ClientProtocolException e) {
Log.d("ClientProtocolException", ""+ e);
}catch(URISyntaxException e){
Log.d("URISyntaxException",""+ e);
} catch (IOException e) {
Log.d("IOException",""+ e);
} catch (JSONException e) {
Log.d("JSONException",""+ e);
}
return null;
}
关于java - JSON 数据错误地填充 textViews,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20615928/
我在activity_main.xml中有一个Textview设计,我想用它来在另一个textview下面显示一个textview。我从 stackoverlow 本身获取了这段代码,并做了一些更改以
伙计们,我尝试添加另一个 TextView ,但是当我尝试时,新的 TextView 已放置在前一个 TextView 上,如何使第二个 TextView 作为新的第二个 TextView 下降 这是
现在 textview 显示如果我将滚动到底部的语句。看起来 promis textview 变大了。有办法解决吗? 星号下的所有内容都是 promis textview 的一部分。它是一个带有多个换
我有多个 TextView 。所有 TextView 都是一个单词。我想用它们来构建一个段落。但他们不应该失去他们的 TextView 功能。因此它们不应该用作字符串。因为那样的话,我希望它们可以一一
附件是指向我的应用程序屏幕截图的链接和显示我想要实现的功能的视频的链接。基本上我想要的是当我单击任何功能区上的“更多”按钮时,它应该自行展开并且用从 JSON 文件中获取的数据替换文本。功能区的高度应
我想显示 edittext 中的文本,但由于输入了大量字符,布局被破坏了。我如何限制在 textview 上显示的字符数 最佳答案 你可以尝试在 Edittext actionlistener 上使用
是否可以将 textview 环绕在 textview 周围,第二个 textview 将环绕到第一个 textview 下的下一行? 例如: 我尝试过使用 android:layout_weig
假设我有 10 个文本项,所有这些项都对用户可见。每个文本项都有不同的颜色和样式。我不知道实现此目标的最佳方法是什么。 多个静态 TextView - 最容易实现,但性能可能最差。 TextView
我正在尝试创建一个布局,其中有两个 TextViews 彼此相邻。第一个 TextView 具有可变长度并且是单行的。第二个 TextView 包含一个固定标签,应该不被省略。第二个标签必须紧挨着第一
我正在使用 onTouchEvent 方法来缩放 TextView ,但是当我有两个 TextView 并且我只想调整第一个 TextView 而不是第二个 TextView 时,我遇到了麻烦。我的意
在我的 android 应用程序中,我有一个自动完成 TextView 字段,可以向用户建议不同的州名称。代码如下: ArrayAdapter state_adapter=new ArrayAdap
我怎样才能让 textview 开始一个新行,一直从左边开始,同时保留属性“toTheRightOf”username25? 像这样: 最佳答案 我的猜测是 twitch 应
我正在做一个动态 TextView 的例子,它是通过按下一个按钮创建的。它们的创建格式类似于: 1- Textview (fist created) 2- TextView 3- TextView (
我想要 TextView 和描述的自动调整大小的文本 here .我想,“测试”这个词应该在单行上对齐,但它是基于字符包装的(参见另一行的“g”)。我应该如何更改我的配置,以便一切都按我的意愿工作?
我有一个简单的布局,在两个 ImageView 之间包含一个 TextView。 当我在运行时使用“setText()”更改 TextView 时,它发生了变化,但失去了“center_horizo
作为 Android 初学者,我正在尝试显示一棵树。我已经找到了如何以编程方式添加新的 TextView,但我不知道如何放置它们,我的意思是如何根据父节点设置它们的填充/边距。 非常感谢您的回答, 巴
对于 AndroidTV,我创建了一个简单的搜索栏和 TextView 。我正在尝试对齐搜索栏拇指的 TextView 并尝试随着进度移动。 尝试了这些解决方案,但不起作用 link1 , link2
我是 Android Studio 新手,正在编写应用程序。 我正在尝试它,我想知道如何在 Textview1 包含某些内容的情况下启用(例如)Textview2。 我尝试了这段代码,但它不起作用:
我从这里获取 TextView 实例: TextView date = null; try { date = (TextView) getLayoutI
这是在别处被问到的,但解决方案对我不起作用。所以用更多的背景再次摆姿势。问题是一个 Activity 包含一个滚动的音乐标题 TextView ,它被更新的耗时计数器 TextView 中断。 我的
我是一名优秀的程序员,十分优秀!