gpt4 book ai didi

java - 我的 ArrayList 显示 NameValuePair 无法解析

转载 作者:太空宇宙 更新时间:2023-11-04 12:57:22 25 4
gpt4 key购买 nike

任何人都可以给我 Android 的 Http get 和 post 请求的完整代码,如下所示 https://wowjava.wordpress.com/2011/01/16/login-application-for-android/。请帮助我想从服务器进行登录检查。所以我想发出一个帖子请求请帮助我。作为新的android开发人员我无法解决这个问题。所以请帮助我。

build.gradle(模块:应用程序):

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.systechdigital.realtimetrackingandmonitoring"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}

我的主要 Activity :

package com.systechdigital.realtimetrackingandmonitoring;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.NameValuePair;



public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {

ImageView icon_image;
ImageView login_image;
EditText username_editText;
EditText password_editText;
Button remember_me_button;
Button forget_password_button;
Button sign_up_button;



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

icon_image =(ImageView)findViewById(R.id.icon_imageView_id);
login_image=(ImageView)findViewById(R.id.imageView_login_id);
username_editText=(EditText)findViewById(R.id.user_login_email_id);
password_editText=(EditText)findViewById(R.id.login_password);
remember_me_button=(Button)findViewById(R.id.remember_me_id);
forget_password_button=(Button)findViewById(R.id.forget_password_id);
sign_up_button=(Button)findViewById(R.id.sign_up_button_id);


login_image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent mainToSignUpIntent=new Intent(getApplicationContext(),SignUPActivity.class);
startActivity(mainToSignUpIntent);

ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();

}
});

}

@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}



@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();

if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_gallery) {

} else if (id == R.id.nav_slideshow) {

} else if (id == R.id.nav_manage) {

} else if (id == R.id.nav_share) {

} else if (id == R.id.nav_send) {

}

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}

最佳答案

ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();

这是错误的声明,您应该提供包含诸如

之类的元素的 arraylist 数据类型,而不是 NameValuePair
ArrayList<String> postParameters = new ArrayList<String>();

关于java - 我的 ArrayList<NameValuePair> 显示 NameValuePair 无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35262625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com