位置: 编程技术 - 正文
推荐整理分享安卓微博评论界面(安卓微博评论界面图片),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:安卓微博评论界面怎么找,手机微博评论rid,安卓微博评论界面图片,微博评论app,微博评论app,手机微博评论,手机微博评论,安卓微博评论界面在哪,内容如对您有帮助,希望把文章链接给更多的朋友!
MainActivity.java
package com.example.ui_listview;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
importandroid.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
importcom.example.ui_listview.adpater.FruitAdapter;
importcom.example.ui_listview.model.Fruit;
public class MainActivity extends Activity{
privateListView lvFruits;
privateList<Fruit> fruitList = new ArrayList<Fruit>();
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initFruits();
lvFruits= (ListView) findViewById(R.id.lvFruits);
FruitAdapter adapter=new FruitAdapter(this,R.layout.fruit_item,fruitList);
lvFruits.setAdapter(adapter);
lvFruits.setOnItemClickListener(newOnItemClickListener() {
publicvoid onItemClick(AdapterView<?> adapterView, View view, int position,
longid) {
Fruit fruit= fruitList.get(position);
Toast.makeText(MainActivity.this,fruit.getName(), Toast.LENGTH_SHORT).show();
}
});
}
privatevoid initFruits() {
Fruit apple = new Fruit("用户", R.drawable.p1,"今天天气真好!","1分钟前");fruitList.add(apple);Fruit banana = new Fruit("笑笑", R.drawable.p2,"今天玩的好高兴!","2分钟前");fruitList.add(banana);Fruit orange = new Fruit("卷毛", R.drawable.p3,"今天首胜没拿?","3分钟前");fruitList.add(orange);Fruit watermelon = new Fruit("小鱼苗", R.drawable.p4,"最近如何呀?","1小时前");fruitList.add(watermelon);Fruit pear = new Fruit("米粒", R.drawable.p5,"你真好!","1.5小时前");fruitList.add(pear);Fruit grape = new Fruit("花花", R.drawable.p6,"我今天中午在学校吃了好多呀!","2小时前");fruitList.add(grape);Fruit pineapple = new Fruit(" 笨笨", R.drawable.p7,"你最近过的咋样啊!","6小时前");fruitList.add(pineapple);Fruit strawberry = new Fruit("晕晕", R.drawable.p8,"我今晚上吃啥呀","1天前");fruitList.add(strawberry);Fruit cherry = new Fruit("哈哈", R.drawable.p,"再见了,各位朋友~","1周前");fruitList.add(cherry);
}
@Override
publicboolean onCreateOptionsMenu(Menu menu) {
//Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main,menu);
returntrue;
}
}
FruitAdapter.java
package com.example.ui_listview.adpater;import java.util.List;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.BaseAdapter;import android.widget.ImageView;import android.widget.TextView;import com.example.ui_listview.R;import com.example.ui_listview.model.Fruit;public class FruitAdapter extends ArrayAdapter<Fruit> {private int resourceId;public FruitAdapter(Context context, int textViewResourceId,List<Fruit> data) {super(context, textViewResourceId, data);resourceId=textViewResourceId;}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {Fruit fruit = getItem(position);View view=LayoutInflater.from(getContext()).inflate(resourceId, null);ImageView ivFruit=(ImageView) view.findViewById(R.id.ivFruit);TextView tvFruit=(TextView) view.findViewById(R.id.tvFruit);TextView textView=(TextView)view.findViewById(R.id.textView);TextView textView2=(TextView)view.findViewById(R.id.textView2);ivFruit.setImageResource(fruit.getImageId());tvFruit.setText(fruit.getName());textView.setText(fruit.getText());textView2.setText(fruit.getTime());return view;}}
FruitAdapterImprove1.java
package com.example.ui_listview.adpater;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.ImageView;import android.widget.TextView;import com.example.ui_listview.R;import com.example.ui_listview.model.Fruit;public class FruitAdapterImprove1 extends ArrayAdapter {private int resourceId;public FruitAdapterImprove1(Context context, int textViewResourceId) {super(context, textViewResourceId);resourceId = textViewResourceId;}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {Fruit fruit = (Fruit) getItem(position);View view=null;if(convertView==null) view = LayoutInflater.from(getContext()).inflate(resourceId, null);else view=convertView;ImageView fruitImage = (ImageView) view.findViewById(R.id.ivFruit);TextView fruitName = (TextView) view.findViewById(R.id.tvFruit);fruitImage.setImageResource(fruit.getImageId());fruitName.setText(fruit.getName());return view;}}
FruitAdapterImprove2.java
package com.example.ui_listview.adpater;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.ImageView;import android.widget.TextView;import com.example.ui_listview.R;import com.example.ui_listview.model.Fruit;public class FruitAdapterImprove2 extends ArrayAdapter {private int resourceId;public FruitAdapterImprove2(Context context, int textViewResourceId) {super(context, textViewResourceId);resourceId = textViewResourceId;}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {Fruit fruit = (Fruit) getItem(position);View view = null;ViewHolder viewHolder;if (convertView == null) {view = LayoutInflater.from(getContext()).inflate(resourceId, null);viewHolder = new ViewHolder();viewHolder.ivFruit = (ImageView) view.findViewById(R.id.ivFruit);viewHolder.tvFruit = (TextView) view.findViewById(R.id.tvFruit);view.setTag(viewHolder);} else {view = convertView;viewHolder = (ViewHolder) convertView.getTag();}viewHolder.ivFruit.setImageResource(fruit.getImageId());viewHolder.tvFruit.setText(fruit.getName());return view;}class ViewHolder {ImageView ivFruit;TextView tvFruit;}}
Fruit.java
package com.example.ui_listview.model;public class Fruit {private String name;private int imageId;private String text;private String time;public Fruit(String name, int imageId, String text, String time) {super();this.name = name;this.imageId = imageId;this.text = text;this.time = time;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getImageId() {return imageId;}public void setImageId(int imageId) {this.imageId = imageId;}public String getText() {return text;}public void setText(String text) {this.text = text;}public String getTime() {return time;}public void setTime(String time) {this.time = time;}}
fruit_item.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView android:id="@id/ivFruit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/p1" /> <TextView android:id="@id/tvFruit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="dp" android:layout_marginLeft="dp" android:layout_toRightOf="@id/ivFruit" android:text="Apple" /> <TextView android:id="@id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@id/tvFruit" android:layout_below="@id/tvFruit" android:layout_marginLeft="dp" android:text="abc" /> <TextView android:id="@id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@id/tvFruit" android:layout_alignBottom="@id/tvFruit" android:layout_alignParentRight="true" android:layout_marginRight="dp" android:text="TextView" /></RelativeLayout>
activity_main.xml
<LinearLayout xmlns:android=" xmlns:tools=" android:id="@id/LinearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <ListView android:id="@id/lvFruits" android:layout_width="match_parent" android:layout_height="wrap_content" > </ListView></LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android=" package="com.example.ui_listview" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/myTheme" > <activity android:name="com.example.ui_listview.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
微软早在年便首次使用了安卓上饱受争议的汉堡按钮 用户在Windows1.0.1系统上发现了相同的汉堡包图标有争议的安卓汉堡菜单和按钮在Windows的电脑和手机上,并且很多人认为微软可能失去它的身份因为它
安卓-新浪微博评论 1.在res/value下建立mytitlebar.xml文件?xmlversion=1.0encoding=utf-8?resourcesxmlns:android=
安卓域名转IP地址(获取Response Header的Location) packagecom.itant.ipconvert;importorg.apache.http.Header;importorg.apache.http.HttpResponse;importorg.apache.http.client.methods.HttpGet;importorg.apache.http.impl.client.DefaultHttpClient;importorg.ap
标签: 安卓微博评论界面图片
本文链接地址:https://www.jiuchutong.com/biancheng/374529.html 转载请保留说明!友情链接: 武汉网站建设