• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Hold Notifications (display notifications at intervals)

AlexeyS

Newbie
Mar 16, 2017
20
2
First Step : import Json file, with two fields : name and id and present only name.

AssyncTask:
....
Code:
protected ArrayList<String> doInBackground(String... params) {
      
 
                for (int i = 0; i < rootArray.length(); i++) {
                 
                    JSONObject NameObject = rootArray.getJSONObject(i);


                    String name = NameObject.getString("Name");
                   String Id = NameObject.getString("ID");

               
                    NameList.add(name);
         }       
}
 
        protected void onPostExecute(ArrayList<String>NameList) {

 
                // TODO add all ArrayList to the adapter!
                adapter.addAll(NameList);
                p.dismiss();
 }



Second Step : when the user click on the name, i have to identify the id and transfer id to A Activity.

Code:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

               Intent intent = new Intent(this, A.class);
                intent.putExtra("id", adapter.getItem(position).toString());
                startActivity(intent);

            }
        });
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones