mirror of
https://github.com/enyason/AndroidLauncherApplication.git
synced 2025-05-17 20:05:54 +08:00
display application list in app drawer screen
This commit is contained in:
@ -98,7 +98,6 @@ public class AppsDrawerAdapter extends RecyclerView.Adapter<AppsDrawerAdapter.Vi
|
|||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
TextToSpeech textToSpeech;
|
|
||||||
public TextView textView;
|
public TextView textView;
|
||||||
public ImageView img;
|
public ImageView img;
|
||||||
|
|
||||||
@ -106,8 +105,8 @@ public class AppsDrawerAdapter extends RecyclerView.Adapter<AppsDrawerAdapter.Vi
|
|||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
//Finds the views from our row.xml
|
//Finds the views from our row.xml
|
||||||
textView = (TextView) itemView.findViewById(R.id.tv_app_name);
|
textView = itemView.findViewById(R.id.tv_app_name);
|
||||||
img = (ImageView) itemView.findViewById(R.id.app_icon);
|
img = itemView.findViewById(R.id.app_icon);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import android.os.Bundle;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -14,14 +16,39 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
public class AppsDrawerFragment extends Fragment {
|
public class AppsDrawerFragment extends Fragment {
|
||||||
|
|
||||||
|
RecyclerView recyclerView;
|
||||||
|
RecyclerView.Adapter adapter;
|
||||||
|
RecyclerView.LayoutManager layoutManager;
|
||||||
|
|
||||||
|
|
||||||
public AppsDrawerFragment() {
|
public AppsDrawerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_apps_drawer,container,false);
|
|
||||||
|
|
||||||
|
View view = inflater.inflate(R.layout.fragment_apps_drawer,container,false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
recyclerView = view.findViewById(R.id.appDrawer_recylerView);
|
||||||
|
|
||||||
|
adapter = new AppsDrawerAdapter(getContext());
|
||||||
|
|
||||||
|
layoutManager = new LinearLayoutManager(getContext());
|
||||||
|
|
||||||
|
|
||||||
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import android.widget.ImageView;
|
|||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
ImageView imageViewDrawer;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -36,8 +35,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
super.onBackPressed();
|
// super.onBackPressed();
|
||||||
|
|
||||||
|
loadFragment(new HomeScreenFragment());
|
||||||
// Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fr)
|
// Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user