0
中添加PARAM我已成功地顯示多個賬戶,名字和電子郵件。但我也希望能夠通過一個唯一的號碼,因爲我傳遞了姓名和電子郵件,以便當我點擊該帳戶時,我可以爲電子郵件,姓名和唯一號碼進行烘烤。目前我只能點擊當前個人資料的名稱和電子郵件。如何在MaterialDrawer
這就是我的Json
"sacco_info": [
{
"name": "Alex Wanjala",
"email": "[email protected]"
"corporate_no": "169500"
}
]
這是我的代碼
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the AccountHeader
Api.getVolley(this, Api.GetCorporateNumber,"{\n" +
" \"authorization_credentials\": {\n" +
" \"api_key\": \""+Const.getInstance().getAuthorizationcredentials().getApi_key()+"\",\n" +
" \"token\": \""+Const.getInstance().getAuthorizationcredentials().getToken()+"\"\n" +
" },\n" +
" \"msisdn\": \""+Const.getInstance().getMember().getMSDN()+"\"\n" +
"}",new Api.VolleyCallback() {
@Override
public void onSuccess(String response) {
try {
JSONObject jsonObj = new JSONObject(response);
JSONArray jsonArray= jsonObj.getJSONArray("sacco_info");
for(int i=0;i<jsonArray.length();i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
profile = new ProfileDrawerItem().withName(jsonObject.getString("name"))
.withEmail(jsonObject.getString("email")).withIcon(getResources().getDrawable(R.drawable.profilepic));
headerResult.addProfiles(profile);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
headerResult = new AccountHeaderBuilder()
.withActivity(DashboardMain.this)
.withHeaderBackground(R.drawable.materiale)
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
Toast.makeText(getApplicationContext(), profile.getEmail().toString(),Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), profile.getName().toString(),Toast.LENGTH_LONG).show();
//Toast the corporate_no here
return false;
}
})
.build();
result = new DrawerBuilder()
.withActivity(DashboardMain.this)
.withToolbar(toolbar)
.withAccountHeader(headerResult)
.addDrawerItems(
item1, item2,item3, item4, item5, item6,
new DividerDrawerItem(),
item7, item8,item9,item10,item11
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
// do something with the clicked item :D
onNavigationItemSelected(position);
return false;
}
})
.build();
或者,如果有一種方法,我可以存儲鍵值對電子郵件作爲陣列中的一個關鍵抱着電子郵件和corparate_no,然後在我實施電子郵件烘烤的時間,它將該電子郵件作爲參數傳遞給存在電子郵件的數組搜索,並返回corpare_no。