我必须使用自定义标题(每个标题中的不同文本)和每个标题下面的不同数量的项目创建自定义列表视图.我一直在阅读各个部分索引示例,但我认为它们与我的答案无关.
任何人请建议我在android中移动这种类型的列表视图的好方法.

我有一个包含20行的列表视图,我想在列表视图中设置一个视图寻呼机作为每一行.由于列表视图的行中的项目可能是一个或多个,我想使用视图寻呼机显示列表视图行项目.
为此,我使用以下代码:
自定义布局,将显示在列表视图行中(作为寻呼机项)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/inner_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6.0dip"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="Example Value"
android:textAppearance="?android:textAppearanceMedium" />
Run Code Online (Sandbox Code Playgroud)
主列表视图具有View Pager的自定义行项目
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<android.support.v4.view.ViewPager
android:id="@+id/mypager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
MyPagerAdapter类
public class MyPagerAdapter extends PagerAdapter {
private Context context;
public MyPagerAdapter(Context context) {
this.context = context;
}
@Override
public int getCount() {
return 4;
}
@Override
public Object instantiateItem(View container, int position) …Run Code Online (Sandbox Code Playgroud) 我正在实施一个演示TIMER,振动(在特定条件下),当我按下启动时,我的计时器开始运行..当我使用停止按钮停止它时,它只是停止.
现在我必须集成一个功能,当人员移动设备时(在Timer运行时),它应该重置计时器.它工作得很好,但加速度计功能并不是绝对准确的.它需要一个快速的反射来重置计时器.
建议我一个很好的解决方案.
这是我的代码
public class SensorAccelerometer implements SensorEventListener {
private Context context;
private SensorManager sensorManager;
private Sensor accelerometer;
private TextView timelabel;
private Handler mHandler;
Runnable run;
private float mLastX, mLastY, mLastZ;
private final float NOISE = (float) 3.0;
public SensorAccelerometer(Context context) {
}
public SensorAccelerometer(Context context,TextView timelabel, Handler mHandler2, Runnable mUpdateTimeTask) {
// TODO Auto-generated constructor stub
this.context = context;
this.timelabel = timelabel;
this.mHandler = mHandler2;
this.run = mUpdateTimeTask;
initialiseSensor();
}
public void initialiseSensor(){
sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); …Run Code Online (Sandbox Code Playgroud) 我正在使用webview并希望加载一个JScode以显示在该webview中.但是我遇到了API16以上的问题.它从不加载JS页面.它给了我一个错误:
这是我的代码:
@JavascriptInterface
public void loadWebviewUrl(){
Map <String, String> extraEncryptionHeaders = new HashMap<String, String>();
extraEncryptionHeaders.put("X-APP-DEVICETYPE", "ANDROID");
appVersionname=CommonMethods.getAppVersion(WebPayUActivity.this);
extraEncryptionHeaders.put("X-APP-APPVERSIONNAME", appVersionname);
extraEncryptionHeaders.put("X-DEVICE", Constant.ANDROIDID);
extraEncryptionHeaders.put(Constant.HEADER_SECURITY_KEY, Constant.SECURITY_HASH_VALUE);
mWebView.loadUrl(mPayUrl, extraEncryptionHeaders);
**//getting error in this line that has been mentioned above**
mWebView.addJavascriptInterface(new Wscript(WebPayUActivity.this),
"Android");
screenDpi=CommonMethods.getResoltuion(this);
mWebView.setWebViewClient(new MyWebViewClient(this));
mImageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
customAlertDialog();
}
});
mWebView.setWebChromeClient(new WebChromeClient());
}
Run Code Online (Sandbox Code Playgroud)
在阅读了不同站点的解决方案后,我知道要添加注释.但在编写注释后,错误仍然是相同的.
任何人都可以检查并帮助我
谢谢
如何在Android GridView中实现拖放功能.任何人都可以提供相同的最佳链接?
我使用以下代码找到Android设备的MAC地址:
WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
String address = info.getMacAddress());
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,当Wifi关闭时,我无法获得MAC地址.即使WIFI关闭,如何获取Android设备的MAC地址.
谢谢
我将View Pager作为List Item行,我将数据设置到寻呼机的适配器以显示在列表视图中.这是我的代码:
Pager_Item布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/inner_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6.0dip"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="Example Value"
android:textAppearance="?android:textAppearanceMedium" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
列表视图行项目
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/mypager"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
ListView GetView
ViewHolder holder;
if(rowView==null){
holder = new ViewHolder();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.horizontal_list_item, parent,false);
MyPagerAdapter adapter = new MyPagerAdapter(context);
ViewPager myPager = (ViewPager) rowView.findViewById(R.id.mypager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(4, true); …Run Code Online (Sandbox Code Playgroud) 我有一个场景,在我的聊天应用程序中我想发送照片,照片发送需要时间.我附上了一个进度条(水平),以显示在我的应用程序中发送照片的进度.但我无法更新进度条,因为它是自定义列表视图的项目.
这是我的asynchtask设置进度条的进度,但我无法得到它.
class SendPhotoToFriend extends AsyncTask<String, String, String>{
String receiver,path = "";
public SendPhotoToFriend(String path,String receiver) {
// TODO Auto-generated constructor stub
this.path = path;
this.receiver = receiver;
}
@Override
protected String doInBackground(String... arg0) {
// TODO Auto-generated method stub
ServiceDiscoveryManager sdm = ServiceDiscoveryManager
.getInstanceFor(connection);
if (sdm == null)
sdm = new ServiceDiscoveryManager(connection);
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
// Create the file transfer manager
FileTransferManager manager = new FileTransferManager(
connection);
FileTransferNegotiator.setServiceEnabled(connection, true);
// Create the outgoing file transfer
OutgoingFileTransfer transfer = manager
.createOutgoingFileTransfer(receiver …Run Code Online (Sandbox Code Playgroud) 我在Android中编辑文本有问题.
我有一个名为Username的字段:
我希望每当有人用空格写一个用户名时,例如"Gaurav Arora".然后它应该在按下登录按钮时提出祝酒或错误.
我这样做了 - 我在文本观察者的帮助下简单地停止了空格键的效果 -
public static TextWatcher getNameTextWatcher(final TextView agrTextView) {
TextWatcher mTextWatcherName = new TextWatcher() {
public void onTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
}
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
}
public void afterTextChanged(Editable arg0) {
String result = agrTextView.getText().toString().replaceAll(" ", "");
if (!agrTextView.getText().toString().equals(result)) {
agrTextView.setText(result);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但这并没有解决我的目的.我只是想实现当人们使用带有空格的用户名时它应该接受空间但是在按下登录按钮时它应该举起一个吐司
谢谢
我想更新 aynctask 中的 textView,但它根本没有更新。我无法找出我的错误。
这是我的代码:
注意:- 当我的应用程序失去焦点并重新获得焦点时,UI 会更新。奇怪的问题
public class LocateGeopoint extends AsyncTask<LatLng, String, List<Address>> {
Geocoder geocoder;
private TextView tv;
public LocateGeopoint(View v) {
this.geocoder = new Geocoder(v.getContext());
this.tv = (TextView) v.findViewById(R.id.textView1);
}
@Override
protected void onPostExecute(List<Address> addresses) {
super.onPostExecute(addresses);
if(addresses!=null){
String city = addresses.get(0).getAddressLine(0);
String country = addresses.get(0).getAddressLine(1);
System.out.println(city+" "+country);
tv.setText(city);
}
}
@Override
protected List<Address> doInBackground(LatLng... params) {
// TODO Auto-generated method stub
double lattitude = params[0].latitude;
double longitude = params[0].longitude;
List<Address> addresses = null;
if (lattitude …Run Code Online (Sandbox Code Playgroud) android textview android-asynctask google-maps-android-api-2
android ×10
listview ×2
android-wifi ×1
gridview ×1
header ×1
height ×1
java ×1
javascript ×1
mac-address ×1
textview ×1
webview ×1
wifimanager ×1