Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7402667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:47:58+00:00 2026-05-29T04:47:58+00:00

I want to define letters in a grid and then highlight it on selected

  • 0

enter image description here

I want to define letters in a grid and then highlight it on selected and if it a valid word.
i can define the letters and show in a grid view.But how to highlight the word as in the figure on selection??
i am developing similar app.Please help.

i copied the image from Word Search App on Android Market.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:47:59+00:00Added an answer on May 29, 2026 at 4:47 am
    • Give unique id to each element – like r1c1, r1c2, etc – Row 1 Col1 , Row 1 Col2 . This will help you later while trapping events and setting colors.
    • Trap onClicked/onSelected/onTouched on each element of the grid.
      You can do this using for loops for each row & col.
    • Initially make nominal changes like draw border on left & right dialonally/straight – This gives the user identication of the selected items.
    • And if the selected elements form a proper word, then change the backgound color of those elements.

    But here you will ahve to take many things under consideration for element :
    If the elements are selected in straight row or col, you can set the background of all grid elements directly. BUT if it is selected diagonally, then you will have to color accrdingly using Drawable. You can create a drawable programmatically of specified color and work out.

    UPDATED :

    In XML, just give the gridLayout.

    In activity in onCreate(), you can work out like this to add contents :

    grid = (GridLayout) findViewById(R.id.myGrid);
    TextView tv = null;
    ViewGroup tvLayParams = null;
    
    for (row=0; row < totalRows; row++) {
       for (cols = 0; cols < totalCols; col++) {
            // Create View
            tv = new TextView();
            tv.setId("r" + row + "_c" + cols);   // 1st row ids will be = r0_c0, r0_c1, r0_c2, r0_c3, etc
            // Set properties like backgound color, etc of button
    
            tvLayParams = (ViewGroup.LayoutParams) tv.getLayoutParams();
            // SET LayoutParams for Button
            tv.setLayoutParams(btnLayParams);
    
            tv.setOnClickListener(this);
            tv.setOnTouchListener(this);
            grid.addView(tv);
       }
    } 
    
    
    @Override
    public void onClick(View v) {
        TextView tv = (TextView)v;
        String id = tv.getId();  // From this you can get the Row & col of the item selected
        int row = ;  // For row, get digit(s) betweeen "r" and "_".
        int col = Integer.parseInt(id.indexOf("c")+1);   // For cols, get digit(s) from "c"
    
        // Draw Borders/shade
        //tv.setDrawable(...);  // Generate drawable based on you need to draw dotted border or background and diagonally or straight.
    
        // Figure out if the word is created
        // If so, make another shade, else let it remain as currently selected & trying to make word
        // Add your logic
    }
    

    This will give you a startup on your problem. Start and try out.
    You can also add all the components in XML instead of adding it via code. But that will make your XML very long and messy too.

    If you get stuck up, feel free. For improvements, you cna create a method to create the button view and just call teh method in inner for loop. But go for this once you are succeded in generating what you want.

    But don’t forget to start and try out first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to define different parameter according to different device, but I got a
I want to define functions that can be used in the fixedpoint rule. For
I want to define a class that supports __getitem__ , but does not allow
I want to show in an alert a french sentence containing accentuated letters such
Foreword: I want to allow users to define high quality document templates and then
I want to define a 'valid' input, which is _-. won't be allowed in
At first sorry my bad English. I want define routing for this url: For
I use emacs in ubuntu 12.04. i want define some background or foreground in
I want to define the data.store that store companyList, because I want to reuse
I want to define a generic function for printing contents of std::map like types.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.