Making gridview items clickable one by one
Level Selection GridView Image
I need to make Level 1 clickable and rest non clickable and when user clicks Level 1 it should make Level 2 clickable and rest non-clickable and so on so forth. Also if user is at Level 5 gridview should be clickable from level 1 to 4
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
//do something
}
private class MyCustomAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers=reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position).equals("true"))
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
}
public class GridObject extends ArrayList<GridObject> {
private int image;
private int state;
public GridObject(int name, int state) {
super();
this.image = name;
this.state = state;
}
public int getName() {
return image;
}
public void setName(int name) {
this.image = name;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
}

|
show 1 more comment
Level Selection GridView Image
I need to make Level 1 clickable and rest non clickable and when user clicks Level 1 it should make Level 2 clickable and rest non-clickable and so on so forth. Also if user is at Level 5 gridview should be clickable from level 1 to 4
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
//do something
}
private class MyCustomAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers=reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position).equals("true"))
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
}
public class GridObject extends ArrayList<GridObject> {
private int image;
private int state;
public GridObject(int name, int state) {
super();
this.image = name;
this.state = state;
}
public int getName() {
return image;
}
public void setName(int name) {
this.image = name;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
}

What you have done so far to achieve same?
– Android Team
Dec 31 '18 at 12:41
Disable all items then enable only the one you need to be clickable.
– Fantômas
Dec 31 '18 at 12:43
Do you have any model for your gridView. share some code so that we can help you :)
– Qadir Hussain
Dec 31 '18 at 12:57
Any ideas......?
– Abdul Manan
Jan 1 at 7:15
@AbdulManan How about inonItemClick()
you compareposition
with your current level and decide whether or not to process the click event? What challenge are you facing exactly?
– Prasad Pawar
Jan 1 at 12:59
|
show 1 more comment
Level Selection GridView Image
I need to make Level 1 clickable and rest non clickable and when user clicks Level 1 it should make Level 2 clickable and rest non-clickable and so on so forth. Also if user is at Level 5 gridview should be clickable from level 1 to 4
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
//do something
}
private class MyCustomAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers=reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position).equals("true"))
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
}
public class GridObject extends ArrayList<GridObject> {
private int image;
private int state;
public GridObject(int name, int state) {
super();
this.image = name;
this.state = state;
}
public int getName() {
return image;
}
public void setName(int name) {
this.image = name;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
}

Level Selection GridView Image
I need to make Level 1 clickable and rest non clickable and when user clicks Level 1 it should make Level 2 clickable and rest non-clickable and so on so forth. Also if user is at Level 5 gridview should be clickable from level 1 to 4
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
//do something
}
private class MyCustomAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers=reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position).equals("true"))
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
}
public class GridObject extends ArrayList<GridObject> {
private int image;
private int state;
public GridObject(int name, int state) {
super();
this.image = name;
this.state = state;
}
public int getName() {
return image;
}
public void setName(int name) {
this.image = name;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
}


edited Dec 31 '18 at 14:58


Fantômas
32.7k156390
32.7k156390
asked Dec 31 '18 at 12:36


Abdul MananAbdul Manan
236
236
What you have done so far to achieve same?
– Android Team
Dec 31 '18 at 12:41
Disable all items then enable only the one you need to be clickable.
– Fantômas
Dec 31 '18 at 12:43
Do you have any model for your gridView. share some code so that we can help you :)
– Qadir Hussain
Dec 31 '18 at 12:57
Any ideas......?
– Abdul Manan
Jan 1 at 7:15
@AbdulManan How about inonItemClick()
you compareposition
with your current level and decide whether or not to process the click event? What challenge are you facing exactly?
– Prasad Pawar
Jan 1 at 12:59
|
show 1 more comment
What you have done so far to achieve same?
– Android Team
Dec 31 '18 at 12:41
Disable all items then enable only the one you need to be clickable.
– Fantômas
Dec 31 '18 at 12:43
Do you have any model for your gridView. share some code so that we can help you :)
– Qadir Hussain
Dec 31 '18 at 12:57
Any ideas......?
– Abdul Manan
Jan 1 at 7:15
@AbdulManan How about inonItemClick()
you compareposition
with your current level and decide whether or not to process the click event? What challenge are you facing exactly?
– Prasad Pawar
Jan 1 at 12:59
What you have done so far to achieve same?
– Android Team
Dec 31 '18 at 12:41
What you have done so far to achieve same?
– Android Team
Dec 31 '18 at 12:41
Disable all items then enable only the one you need to be clickable.
– Fantômas
Dec 31 '18 at 12:43
Disable all items then enable only the one you need to be clickable.
– Fantômas
Dec 31 '18 at 12:43
Do you have any model for your gridView. share some code so that we can help you :)
– Qadir Hussain
Dec 31 '18 at 12:57
Do you have any model for your gridView. share some code so that we can help you :)
– Qadir Hussain
Dec 31 '18 at 12:57
Any ideas......?
– Abdul Manan
Jan 1 at 7:15
Any ideas......?
– Abdul Manan
Jan 1 at 7:15
@AbdulManan How about in
onItemClick()
you compare position
with your current level and decide whether or not to process the click event? What challenge are you facing exactly?– Prasad Pawar
Jan 1 at 12:59
@AbdulManan How about in
onItemClick()
you compare position
with your current level and decide whether or not to process the click event? What challenge are you facing exactly?– Prasad Pawar
Jan 1 at 12:59
|
show 1 more comment
2 Answers
2
active
oldest
votes
If I read it correctly, you want a "current level" that allows you to check/uncheck any grid item up to that level and allow you also to click on the item for the next level to make that the new current level.
If so, then it is simple to modify your adapter by adding a currentLevel
variable and adjusting getView()
to enable clicking on items up to and including this level.
Here is an updated version of your adapter showing this:
private class MyCustomAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
private LayoutInflater mInflater;
// implement check as boolean array rather than what appears to be string array
private final SparseBooleanArray check = new SparseBooleanArray();
// keep track of the current level
private int currentLevel = 0;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers = reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position)) // used to be ...equals("true")
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
// make items up to current level clickable
convertView.setClickable(currentLevel < position);
// show unclickable items as disabled
convertView.setEnabled(currentLevel >= position);
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// increase the current level if the item for the current level is clicked
currentLevel = Math.max(currentLevel, position + 1);
// toggle the checked state for the clicked item
check.put(position, !check.get(position, false));
// refresh the views
notifyDataSetChanged();
}
}
You can then enable this on your GridView in a similar way as before:
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(myAdapter);
Note that I have implemented the missing check
list as a SparseBooleanArray
rather than what looks like an array of strings with "true"
and "false"
values in your version. You can change it back if you prefer.
add a comment |
I have Used a Simple Check list boolean = gridview items and It Works....By Default I have set the first value true and the rest value false.......
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long
id)
{
if (clickcheck.get(position).equals(true)) {
//complete some task then
position=position+1;
clickcheck.remove(position);
clickcheck.add(position,true);
}
else
{
Toast.makeText(getActivity(), "Click On Level "+position, Toast.LENGTH_SHORT).show();
}
`
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53987618%2fmaking-gridview-items-clickable-one-by-one%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If I read it correctly, you want a "current level" that allows you to check/uncheck any grid item up to that level and allow you also to click on the item for the next level to make that the new current level.
If so, then it is simple to modify your adapter by adding a currentLevel
variable and adjusting getView()
to enable clicking on items up to and including this level.
Here is an updated version of your adapter showing this:
private class MyCustomAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
private LayoutInflater mInflater;
// implement check as boolean array rather than what appears to be string array
private final SparseBooleanArray check = new SparseBooleanArray();
// keep track of the current level
private int currentLevel = 0;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers = reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position)) // used to be ...equals("true")
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
// make items up to current level clickable
convertView.setClickable(currentLevel < position);
// show unclickable items as disabled
convertView.setEnabled(currentLevel >= position);
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// increase the current level if the item for the current level is clicked
currentLevel = Math.max(currentLevel, position + 1);
// toggle the checked state for the clicked item
check.put(position, !check.get(position, false));
// refresh the views
notifyDataSetChanged();
}
}
You can then enable this on your GridView in a similar way as before:
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(myAdapter);
Note that I have implemented the missing check
list as a SparseBooleanArray
rather than what looks like an array of strings with "true"
and "false"
values in your version. You can change it back if you prefer.
add a comment |
If I read it correctly, you want a "current level" that allows you to check/uncheck any grid item up to that level and allow you also to click on the item for the next level to make that the new current level.
If so, then it is simple to modify your adapter by adding a currentLevel
variable and adjusting getView()
to enable clicking on items up to and including this level.
Here is an updated version of your adapter showing this:
private class MyCustomAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
private LayoutInflater mInflater;
// implement check as boolean array rather than what appears to be string array
private final SparseBooleanArray check = new SparseBooleanArray();
// keep track of the current level
private int currentLevel = 0;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers = reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position)) // used to be ...equals("true")
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
// make items up to current level clickable
convertView.setClickable(currentLevel < position);
// show unclickable items as disabled
convertView.setEnabled(currentLevel >= position);
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// increase the current level if the item for the current level is clicked
currentLevel = Math.max(currentLevel, position + 1);
// toggle the checked state for the clicked item
check.put(position, !check.get(position, false));
// refresh the views
notifyDataSetChanged();
}
}
You can then enable this on your GridView in a similar way as before:
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(myAdapter);
Note that I have implemented the missing check
list as a SparseBooleanArray
rather than what looks like an array of strings with "true"
and "false"
values in your version. You can change it back if you prefer.
add a comment |
If I read it correctly, you want a "current level" that allows you to check/uncheck any grid item up to that level and allow you also to click on the item for the next level to make that the new current level.
If so, then it is simple to modify your adapter by adding a currentLevel
variable and adjusting getView()
to enable clicking on items up to and including this level.
Here is an updated version of your adapter showing this:
private class MyCustomAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
private LayoutInflater mInflater;
// implement check as boolean array rather than what appears to be string array
private final SparseBooleanArray check = new SparseBooleanArray();
// keep track of the current level
private int currentLevel = 0;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers = reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position)) // used to be ...equals("true")
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
// make items up to current level clickable
convertView.setClickable(currentLevel < position);
// show unclickable items as disabled
convertView.setEnabled(currentLevel >= position);
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// increase the current level if the item for the current level is clicked
currentLevel = Math.max(currentLevel, position + 1);
// toggle the checked state for the clicked item
check.put(position, !check.get(position, false));
// refresh the views
notifyDataSetChanged();
}
}
You can then enable this on your GridView in a similar way as before:
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(myAdapter);
Note that I have implemented the missing check
list as a SparseBooleanArray
rather than what looks like an array of strings with "true"
and "false"
values in your version. You can change it back if you prefer.
If I read it correctly, you want a "current level" that allows you to check/uncheck any grid item up to that level and allow you also to click on the item for the next level to make that the new current level.
If so, then it is simple to modify your adapter by adding a currentLevel
variable and adjusting getView()
to enable clicking on items up to and including this level.
Here is an updated version of your adapter showing this:
private class MyCustomAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
private LayoutInflater mInflater;
// implement check as boolean array rather than what appears to be string array
private final SparseBooleanArray check = new SparseBooleanArray();
// keep track of the current level
private int currentLevel = 0;
public MyCustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GridObject object = my.get(position);
GridObject revers = reverseobj.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_set, null);
holder = new ViewHolder();
holder.text = (ImageView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
if (check.get(position)) // used to be ...equals("true")
{
holder.text.setImageResource(revers.getName());
}
else {
holder.text.setImageResource(object.getName());
}
// make items up to current level clickable
convertView.setClickable(currentLevel < position);
// show unclickable items as disabled
convertView.setEnabled(currentLevel >= position);
return convertView;
}
@Override
public int getCount() {
return my.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// increase the current level if the item for the current level is clicked
currentLevel = Math.max(currentLevel, position + 1);
// toggle the checked state for the clicked item
check.put(position, !check.get(position, false));
// refresh the views
notifyDataSetChanged();
}
}
You can then enable this on your GridView in a similar way as before:
myAdapter = new MyCustomAdapter(getActivity());
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(myAdapter);
Note that I have implemented the missing check
list as a SparseBooleanArray
rather than what looks like an array of strings with "true"
and "false"
values in your version. You can change it back if you prefer.
edited Jan 1 at 12:23
answered Jan 1 at 12:14
AGDownieAGDownie
21615
21615
add a comment |
add a comment |
I have Used a Simple Check list boolean = gridview items and It Works....By Default I have set the first value true and the rest value false.......
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long
id)
{
if (clickcheck.get(position).equals(true)) {
//complete some task then
position=position+1;
clickcheck.remove(position);
clickcheck.add(position,true);
}
else
{
Toast.makeText(getActivity(), "Click On Level "+position, Toast.LENGTH_SHORT).show();
}
`
add a comment |
I have Used a Simple Check list boolean = gridview items and It Works....By Default I have set the first value true and the rest value false.......
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long
id)
{
if (clickcheck.get(position).equals(true)) {
//complete some task then
position=position+1;
clickcheck.remove(position);
clickcheck.add(position,true);
}
else
{
Toast.makeText(getActivity(), "Click On Level "+position, Toast.LENGTH_SHORT).show();
}
`
add a comment |
I have Used a Simple Check list boolean = gridview items and It Works....By Default I have set the first value true and the rest value false.......
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long
id)
{
if (clickcheck.get(position).equals(true)) {
//complete some task then
position=position+1;
clickcheck.remove(position);
clickcheck.add(position,true);
}
else
{
Toast.makeText(getActivity(), "Click On Level "+position, Toast.LENGTH_SHORT).show();
}
`
I have Used a Simple Check list boolean = gridview items and It Works....By Default I have set the first value true and the rest value false.......
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long
id)
{
if (clickcheck.get(position).equals(true)) {
//complete some task then
position=position+1;
clickcheck.remove(position);
clickcheck.add(position,true);
}
else
{
Toast.makeText(getActivity(), "Click On Level "+position, Toast.LENGTH_SHORT).show();
}
`
edited Jan 2 at 6:32
answered Jan 1 at 12:48


Abdul MananAbdul Manan
236
236
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53987618%2fmaking-gridview-items-clickable-one-by-one%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What you have done so far to achieve same?
– Android Team
Dec 31 '18 at 12:41
Disable all items then enable only the one you need to be clickable.
– Fantômas
Dec 31 '18 at 12:43
Do you have any model for your gridView. share some code so that we can help you :)
– Qadir Hussain
Dec 31 '18 at 12:57
Any ideas......?
– Abdul Manan
Jan 1 at 7:15
@AbdulManan How about in
onItemClick()
you compareposition
with your current level and decide whether or not to process the click event? What challenge are you facing exactly?– Prasad Pawar
Jan 1 at 12:59