Kalpana Nautiyal
Newbie
I am developing an app and requires to make 15-16 pages then should I choose activity or fragments?
Please help me to reach at a decision I am very confused.
Please help me to reach at a decision I am very confused.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.

how can i retrieve the data from any web and display it in a customize manner. I can use WebView but it shows the data same as web and i want to customize it so what's the way to do it?
Please post Getview method from your adapter class.How can I apply itemclicklistener on a gridview in the fragment? It does not respond to my code which is normally used. It is not print the log also and no errors are there.
Here is my code:
grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.e("<<<<","Click");
Toast.makeText(getActivity(),"hello",Toast.LENGTH_LONG).show();
}
});
Please help me to solve this issue and thanks for previous answers
View view=inflater.inflate(R.layout.fragment_fraghome,null);
View view=inflater.inflate(R.layout.fragment_fraghome, container, false);
public class Fraghome extends Fragment {
ArrayList<Integer>pics_array;
ArrayList<String>text_array;
GridView grid;
Context context;
public Fraghome() {
// Required empty public constructor
}
[USER=1021285]@override[/USER]
public void onAttach(Context context) {
super.onAttach(context);
this.context=context;
}
[USER=1021285]@override[/USER]
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_fraghome,container,false);
pics_array=new ArrayList<>();
pics_array.add(R.drawable.squiiz);
pics_array.add(R.drawable.sblog);
pics_array.add(R.drawable.sgallery);
pics_array.add(R.drawable.scourses);
pics_array.add(R.drawable.sonline);
pics_array.add(R.drawable.sportfolio);
pics_array.add(R.drawable.sfaculty);
pics_array.add(R.drawable.stestimonial);
pics_array.add(R.drawable.sfaq);
pics_array.add(R.drawable.sstudentlife);
pics_array.add(R.drawable.sabout);
pics_array.add(R.drawable.svideos);
text_array=new ArrayList<>();
text_array.add("Quizzes");
text_array.add("Blogs");
text_array.add("Gallery");
text_array.add("Courses");
text_array.add("Online Courses");
text_array.add("Portfolio");
text_array.add("Faculties");
text_array.add("Testimonial");
text_array.add("FAQs");
text_array.add("Student's Life");
text_array.add("About us");
text_array.add("Video");
grid=view.findViewById(R.id.grid);
GridAdapter adapter =new GridAdapter(getActivity(),pics_array,text_array);
grid.setAdapter(adapter);
Toast.makeText(getActivity(),"hello",Toast.LENGTH_LONG).show();
Log.e("<<<<","Click outside");
grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
[USER=1021285]@override[/USER]
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
// String id=adapterView.getItemAtPosition(i).toString();
String id= String.valueOf(adapterView.getSelectedItemId());
Log.e("<<<<","Click");
Toast.makeText(getActivity(),id+"hello",Toast.LENGTH_LONG).show();
}
});
return view;
}
}
public class GridAdapter extends BaseAdapter {
ArrayList<Integer>pics_array;
ArrayList<String>text_array;
Context context;
LayoutInflater inflater;
public GridAdapter(FragmentActivity fraghome, ArrayList<Integer> pics_array, ArrayList<String> text_array) {
this.pics_array=pics_array;
this.text_array=text_array;
this.context=fraghome;
inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
[USER=1021285]@override[/USER]
public int getCount() {
return pics_array.size();
}
[USER=1021285]@override[/USER]
public Object getItem(int i) {
return i;
}
[USER=1021285]@override[/USER]
public long getItemId(int i) {
return i;
}
[USER=1021285]@override[/USER]
public View getView(int i, View view, ViewGroup viewGroup) {
Holder holder=new Holder();
view=inflater.inflate(R.layout.gridcontent,null);
holder.imgbtn=view.findViewById(R.id.img);
holder.txtview=view.findViewById(R.id.txt);
holder.imgbtn.setImageResource(pics_array.get(i));
holder.txtview.setText(text_array.get(i));
return view;
}
class Holder {
ImageButton imgbtn;
TextView txtview;
}
}
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.admecmultimediainstitute.admec.Fraghome">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="550dp">
<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="500dp"
android:numColumns="3"/>
</RelativeLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:eek:rientation="vertical"
android:layout_height="match_parent">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img"
android:focusable="false"
android:focusableInTouchMode="false"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txt"
android:textAlignment="center"
android:paddingLeft="10dp"/>
</LinearLayout>
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setLogo(R.drawable.toologo);
toolbar.setTitle("ADMEC MULTIMEDIA INSTITUTE");
toolbar.setPadding(0,0,0,0);
toolbar.setContentInsetsAbsolute(0,0);
setSupportActionBar(toolbar);
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="start"
android:background="?attr/colorPrimary"
android:longClickable="false"
android:textAlignment="viewStart"
app:logo="@drawable/toologo"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="ADMEC MULTIMEDIA INSTITUTE"
android:padding="0dp"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:titleMargin="0dp" />
android:padding="0dp"
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"
android:background="#de080a"
app:title="LOGIN"
android:textAlignment="center"
app:titleTextColor="@color/cardview_light_background"
android:layout_centerHorizontal="true"
android:gravity="center"
android:foregroundGravity="center"
>
</android.support.v7.widget.Toolbar>
[code]
[code]
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setLogo(R.drawable.toologo);
toolbar.setTitle("ADMEC MULTIMEDIA INSTITUTE");
toolbar.setPadding(0,0,0,0);
//toolbar.setContentInsetsAbsolute(0,0);
setSupportActionBar(toolbar);
[code]
Please give me a solution