1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-11-23 12:16:13 -06:00

Add gridview (not working)

This commit is contained in:
RicomenPL 2017-07-15 19:33:28 +02:00
parent 538721003e
commit 6e6a053adb
13 changed files with 104 additions and 13 deletions

View File

@ -18,7 +18,7 @@ import io.github.wulkanowy.activity.dashboard.marks.MarksFragment;
public class DashboardActivity extends AppCompatActivity {
MarksFragment marksFragment = new MarksFragment();
MarksFragment marksFragment;
AttendanceFragment attendanceFragment = new AttendanceFragment();
BoardFragment boardFragment = new BoardFragment();
LessonplanFragment lessonplanFragment = new LessonplanFragment();
@ -68,6 +68,8 @@ public class DashboardActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
marksFragment = new MarksFragment();
setTitle(R.string.title_dashboard);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);

View File

@ -0,0 +1,62 @@
package io.github.wulkanowy.activity.dashboard.marks;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import io.github.wulkanowy.R;
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
this.mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
// if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
// references to our images
private Integer[] mThumbIds = {
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7
};
}

View File

@ -1,16 +1,30 @@
package io.github.wulkanowy.activity.dashboard.marks;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import io.github.wulkanowy.R;
public class MarksFragment extends Fragment {
Activity mActivity;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mActivity = (Activity) context;
}
public MarksFragment() {
}
@ -19,6 +33,18 @@ public class MarksFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_marks, container, false);
GridView gridview = (GridView) view.findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(mActivity));
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(mActivity,"HALLO", Toast.LENGTH_SHORT).show();
}
});
return inflater.inflate(R.layout.fragment_marks, container, false);
}

View File

@ -31,7 +31,7 @@ public class LoadingTask extends AsyncTask<Void, Void, Void> {
/* Intent intent = new Intent(activity,MainActivity.class);
activity.startActivity(intent); */
Intent intent = new Intent(activity,MainActivity.class);
Intent intent = new Intent(activity,DashboardActivity.class);
activity.startActivity(intent);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -1,17 +1,18 @@
<FrameLayout 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="io.github.wulkanowy.activity.dashboard.marks.MarksFragment">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="io.github.wulkanowy.activity.dashboard.marks.MarksFragment">
<TextView
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Fragment Oceny" />
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:gravity="center"
/>
</FrameLayout>