tab studio programacion iconos hermosa example español con activity android android-intent navigation tabview

studio - ¿Cómo navegar en la aplicación de pestañas en Android? con mis clases de fuentes



tabs android studio material design (0)

// La cuarta más abajo es la actividad de la cuarta pestaña en mi proyecto, así que dentro tengo otras actividades más, como MasjidsearchActivity en el ítem. Se muestra como actividad separada, pero quiero con las pestañas restantes

package com.hands.iagd.app; import java.util.ArrayList; import java.util.List; import android.R.layout; import android.R.string; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleAdapter; public class Fourth extends Activity { static String[] values,Masjeed,Alaram; String[] adjust_calender; ListView lv1,lv2,lv3,lv4; public static List<String> Calculation_method=new ArrayList<String>(); int index,index2; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.fourth); lv1=(ListView)findViewById(R.id.lv1); lv2=(ListView)findViewById(R.id.lv2); lv3=(ListView)findViewById(R.id.lv3); lv4=(ListView)findViewById(R.id.lv4); values = new String[] {"Jafari","Karachi","ISNA","MWL","Makkah","Egypt","Custom","Tehran"}; Masjeed = new String[] {"IAGD Masjid"}; Alaram = new String[] {""}; String hijriString="Hijri Calender "+Adjust_Time.hijriAdjust; adjust_calender= new String[]{hijriString}; lv1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice,values)); lv1.setChoiceMode(ListView.CHOICE_MODE_SINGLE); index=First.index; lv1.setItemChecked(index, true); lv1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub index=arg2; First.index=arg2; System.out.println("index " +index); } }); Masjeed=MasjidsearchActivity.selectedmasjid; lv2.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,Masjeed)); lv2.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lv2.setItemChecked(index2, true); lv2.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub index2=arg2; First.index2=arg2; System.out.println("index " +index2); Intent masjid=new Intent(Fourth.this,MasjidsearchActivity.class); startActivity(masjid); } }); lv3.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,adjust_calender)); lv3.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub Adjust_Time.sahurORiftar="hijri"; Intent i=new Intent(Fourth.this,Adjust_Time.class); startActivity(i); } }); } @Override protected void onResume() { // TODO Auto-generated method stub String hijriString="Hijri Calender "+Adjust_Time.hijriAdjust; adjust_calender= new String[]{hijriString}; lv1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice,values)); lv1.setChoiceMode(ListView.CHOICE_MODE_SINGLE); index=First.index; lv1.setItemChecked(index, true); lv2.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice,Masjeed)); lv2.setChoiceMode(ListView.CHOICE_MODE_SINGLE); index2=First.index2; lv2.setItemChecked(index2, true); lv3.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,adjust_calender)); super.onResume(); } }

// aquí está la clase MasjidsearchActivity

package com.hands.iagd.app; /** * ©2010 by androidblogger.ch */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Hashtable; import java.util.List; import android.app.Activity; import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ContextMenu.ContextMenuInfo; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.RadioButton; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; public class MasjidsearchActivity extends Activity { RadioButton rb1 ; Button b1,btn; EditText edittext; ListView mainListView; static String[] selectedmasjid=new String[] {"IAGD Masjid"};; List<Hashtable<String,String>> list1 = new ArrayList<Hashtable<String,String>>(); int textlength = 0; ArrayList<String> text_sort = new ArrayList<String>(); ArrayList<Integer> image_sort = new ArrayList<Integer>(); ArrayList<String> text_sort2 = new ArrayList<String>(); // ArrayList which contains our HashMap''s with different objects private ArrayList<HashMap<String, Object>> myList; private ArrayList<HashMap<String, Object>> myList1; private ArrayList<HashMap<String, Object>> filterList; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.masjidlist); b1=(Button)findViewById(R.id.button1); btn=(Button)findViewById(R.id.btn); btn.setOnCreateContextMenuListener(this); //rb1=(RadioButton)findViewById(R.id.radioButton1); /*rb1.setOnClickListener(new OnClickListener() { public void onClick(View v) { System.out.println( "inside radio buttons" ); }});*/ mainListView = (ListView) findViewById(R.id.main_listview); b1.setOnClickListener(new OnClickListener() { public void onClick(View v) { IAGDAPPActivity.settingCurrentTab=3; Intent int1 = new Intent(MasjidsearchActivity.this, IAGDAPPActivity.class); startActivity(int1); }}); edittext = (EditText) findViewById(R.id.search_mycontact); // Create Hash Map myList = new ArrayList<HashMap<String, Object>>(); myList1 = new ArrayList<HashMap<String, Object>>(); filterList = new ArrayList<HashMap<String, Object>>(); edittext.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { textlength = edittext.getText().length(); text_sort.clear(); image_sort.clear(); text_sort2.clear(); filterList.clear(); for (int i = 0; i < myList1.size(); i++) { HashMap<String,Object> maps=new HashMap<String, Object>(); maps=myList1.get(i); String masjidName=maps.get("MosquesNames").toString(); String cityName=maps.get("MosqueCity").toString(); List<String> searchStrring = new ArrayList<String>(Arrays.asList(masjidName.split(" "))); searchStrring.add(masjidName); searchStrring.add(cityName); for (String s123 : searchStrring) { if (textlength <= s123.length()) { if (edittext.getText().toString(). equalsIgnoreCase((String) s123.subSequence(0, textlength))) { filterList.add(maps); break; } } /* if (edittext.getText().toString(). equalsIgnoreCase((String) masjidName.subSequence(0, textlength))) { //text_sort.add(month[i]); //image_sort.add(image[i]); // text_sort2.add(desc[i]); filterList.add(maps); }*/ } } displayList(filterList); mainListView = (ListView) findViewById(R.id.main_listview); mainListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); System.out.println("****3"); } }); // Fill data // addDataToList(); addDBFROMCSV(); // View mainListView = (ListView) findViewById(R.id.main_listview); // Adapter /* SimpleAdapter aa = new SimpleAdapter(this, myList, R.layout.row, new String[] {"name", "address", "city", "icon"}, new int[] {R.id.txt_name, R.id.txt_town, R.id.txt_phone, R.id.img_user}); mainListView.setAdapter(aa);*/ /* SimpleAdapter aa = new SimpleAdapter(this, myList1, R.layout.row, new String[] {"MosquesNames", "MosqueAddress", "MosqueCity","icon"}, new int[] {R.id.txt_name, R.id.txt_town, R.id.txt_phone, R.id.img_user}); mainListView.setAdapter(aa); */ displayList(myList1); // Listener mainListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mainListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Get the HashMap of the clicked item HashMap<String, Object> user = myList1.get(position); // Get Attribute name of the HashMap String name = (String)user.get("MosquesNames"); selectedmasjid =new String[] {name}; System.out.println("name:"+selectedmasjid.length); // Create new Dialog final Dialog dialog = new Dialog(MasjidsearchActivity.this); dialog.setTitle(" " + name); TextView txtDescription = new TextView(MasjidsearchActivity.this); txtDescription.setPadding(10, 0, 0, 10); txtDescription.setText("Masjid Selected"); dialog.setContentView(txtDescription); dialog.setCanceledOnTouchOutside(true); dialog.show(); } }); } public void onCreateContextMenu(ContextMenu menu, View view,ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); CreateMenu(menu); } @Override public boolean onContextItemSelected(MenuItem item) { return MenuChoice(item); } private void CreateMenu(Menu menu) { MenuItem mnu1 = menu.add(0, 0, 0, "Register with us"); { mnu1.setAlphabeticShortcut(''a''); //mnu1.setIcon(R.drawable.image1); } MenuItem mnu2 = menu.add(0, 1, 1, "Notify about your Masjid "); { mnu2.setAlphabeticShortcut(''b''); //mnu2.setIcon(R.drawable.image2); } MenuItem mnu3 = menu.add(0, 2, 2, "Cancel"); { mnu3.setAlphabeticShortcut(''c''); //mnu3.setIcon(R.drawable.image3); } /* MenuItem mnu4 = menu.add(0, 3, 3, "Item 4"); { mnu4.setAlphabeticShortcut(''d''); } menu.add(0, 4,4, "Item 5"); menu.add(0, 5,5, "Item 6"); menu.add(0, 6,6, "Item 7");*/ } private boolean MenuChoice(MenuItem item) { switch (item.getItemId()) { case 0: Intent i=new Intent(MasjidsearchActivity.this,Register.class); startActivity(i); //Toast.makeText(this, "You clicked on Notify",Toast.LENGTH_LONG).show(); return true; case 1: Intent i1=new Intent(MasjidsearchActivity.this,masjidnotify.class); startActivity(i1); //Toast.makeText(this, "You clicked on Register",Toast.LENGTH_LONG).show(); return true; case 2: //Toast.makeText(this, "You clicked on Cancel",Toast.LENGTH_LONG).show(); return true; /*case 3: Toast.makeText(this, "You clicked on Item 4",Toast.LENGTH_LONG).show(); return true;*/ /* case 4: Toast.makeText(this, "You clicked on Item 5",Toast.LENGTH_LONG).show(); return true; case 5: Toast.makeText(this, "You clicked on Item 6",Toast.LENGTH_LONG).show(); return true; case 6: Toast.makeText(this, "You clicked on Item 7",Toast.LENGTH_LONG).show(); return true;*/ } return false; } private void displayList(ArrayList<HashMap<String, Object>> myLists) { SimpleAdapter aa = new SimpleAdapter(this, myLists, R.layout.row, new String[] {"MosquesNames", "MosqueAddress", "MosqueCity","icon"}, new int[] {R.id.txt_name, R.id.txt_town, R.id.txt_phone, R.id.img_user}); mainListView.setAdapter(aa); mainListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); } private void addDBFROMCSV() { InputStream is = this.getResources().openRawResource (R.raw.listofmosquesinusa); BufferedReader reader = new BufferedReader(new InputStreamReader (is)); try { ArrayList< String> list=new ArrayList<String>(); String line; while ((line = reader.readLine()) != null) { // do something with "line" // System.out.println("llllll"+line); list.add(line); } // System.out.println("llllll"+list); ArrayList<List<String>> arrayList=new ArrayList<List<String>>(); for(int i=0;i<list.size();i++) { String s1=list.get(i); List<String> list12 = new ArrayList<String>(Arrays.asList(s1.split("123456COLUMNDEVIDER"))); // System.out.println("List1 is "+list1); // System.out.println("List size is "+list1.size()); arrayList.add(list12); } ArrayList<List<String>> updatedList =new ArrayList<List<String>>(); for(int k=0;k<arrayList.size();k++) { List<String> l111=new ArrayList<String>(); List<String> l1=new ArrayList<String>(); l1=arrayList.get(k); for(int j=0;j<l1.size();j++) { String sss1=l1.get(j); if(sss1.length()<2) { l111.add(" "); // System.out.println("Values in empty"+sss1); } else { char c1=sss1.charAt(0); if(c1=='','' ) { sss1=sss1.substring(1); } c1=sss1.charAt(sss1.length()-1); if(c1=='','' ) { sss1=sss1.substring(0,sss1.lastIndexOf(",")); } l111.add(sss1); //System.out.println("Values in "+sss1); } } updatedList.add(l111); } System.out.println("updated list"+updatedList); ArrayList<String> tblList=new ArrayList<String>(); for(int i=0;i<updatedList.size();i++) { List<String> oneList=updatedList.get(i); String x1=oneList.get(0); String x2=oneList.get(1); String x3=oneList.get(2); String x4=oneList.get(3); String x5=oneList.get(4); String x6=oneList.get(5); String x7=oneList.get(6); String x8=oneList.get(7); String x9=oneList.get(8); String x10=oneList.get(9); // String x11=oneList.get(10); Hashtable<String, String> hm = new Hashtable<String, String>(); hm.put("Sno", x1); hm.put("MosquesNames", x2); hm.put("MosqueAddress", x3); hm.put("MosqueCity", x4); hm.put("Mosquestate", x5); hm.put("Mosquezip", x6); hm.put("Mosquecountry", x7); hm.put("Mosquephn1", x8); hm.put("Mosquephn2", x9); hm.put("Mosquephn3", x10); //hm.put("Mosquephn3", x10); // hm.put("icon", R.drawable.images); HashMap<String, Object> map1 = new HashMap<String, Object>(); map1.put("Sno", x1); map1.put("MosquesNames", x2); map1.put("MosqueAddress", x3); map1.put("MosqueCity", x4); map1.put("Mosquestate", x5); map1.put("Mosquezip", x6); map1.put("Mosquecountry", x7); map1.put("Mosquephn1", x8); map1.put("Mosquephn2", x9); map1.put("Mosquephn3", x10); map1.put("icon", R.drawable.images); myList1.add(map1); // list1.add(hm) ; // add=hm.get("MosquesNames")+" "+hm.get("MosqueAddress")+" "+hm.get("MosqueCity"); //tblList.add(add); } System.out.println("new:"+myList1); } catch (IOException ex) { // handle exception } finally { try { is.close(); } catch (IOException e) { // handle exception } } } /** * This method is used, to fill data into our List */ private void addDataToList(){ HashMap<String, Object> map1 = new HashMap<String, Object>(); map1.put("icon", R.drawable.images); map1.put("name", "Al-Masjidul Al-Kaa''Bah"); map1.put("address", "691 Idlewild Circle - Suite H"); map1.put("city", "Birmingham, Alabama"); HashMap<String, Object> map2 = new HashMap<String, Object>(); map2.put("icon",R.drawable.images); map2.put("name", "Al-Masjidul Al-Kaa''Bah "); map2.put("address", "691 Idlewild Circle - Suite H"); map2.put("city", "Birmingham, Alabama"); HashMap<String, Object> map3 = new HashMap<String, Object>(); map3.put("icon", R.drawable.images); map3.put("name", "Birmingham Islamic Society"); map3.put("address", " "); map3.put("city", "Birmingham, Alabama"); HashMap<String, Object> map4 = new HashMap<String, Object>(); map4.put("icon", R.drawable.images); map4.put("name", "Birmingham Mosque"); map4.put("address","1534 19th Street"); map4.put("city", "Birmingham, Alabama"); HashMap<String, Object> map5 = new HashMap<String, Object>(); map5.put("icon", R.drawable.images); map5.put("name", "Masjid Al-Quran"); map5.put("address", " "); map5.put("city", "Birmingham, Alabama"); myList.add(map1); myList.add(map2); myList.add(map3); myList.add(map4); myList.add(map5); } }