Карта намерений внутри ArrayList - PullRequest
0 голосов
/ 05 октября 2018

Я создаю приложение, которое является гидом по городу.У меня есть категории, такие как еда, аттракционы и т. Д. Внутри каждой категории я сделал список с помощью специального адаптера массива.внутри списка массивов хранятся изображения, описание каждого места и адрес.Я пытаюсь установить прослушиватель onclick для адресной части, и при нажатии он отображает карты с указанием местоположения.это мой код до сих пор.Я получаю сообщение об ошибке с Override onClick, в котором говорится, что «метод не переопределяет метод из своего суперкласса».

'public class DinnerFragment extends Fragment {

public DinnerFragment() {
    // Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.list_view, container, false);

    final TextView address = (TextView) rootView.findViewById(R.id.address);
    //Create a list for locations
    ArrayList<List> locations = new ArrayList<List>();

    locations.add(new List("Coconuts", "Chill, beachy hangout on the Intracoastal dishing seafood & Sunday brunch while yachts cruise by.", "429 Seabreeze Blvd, Fort Lauderdale, FL 33316" , R.drawable.coconuts));
    locations.add(new List("Trulucks","Upscale seafood & steak chain featuring half-price happy hours, a deep wine list & swanky surrounds", "2584A E Sunrise Blvd, Fort Lauderdale, FL 33304", R.drawable.trulucks ));
    locations.add(new List("Pirate Republic", "Lively riverfront spot with a Caribbean-Mediterranean menu, live music & weeknight happy hour.", "400 SW 3rd Ave, Fort Lauderdale, FL 33315", R.drawable.pirate_republic ));
    locations.add(new List("15th Street Fisheries", "Veteran marina eatery dishing upscale & casual fare with live music & tarpon feeding from the dock.", "1900 SE 15th St, Fort Lauderdale, FL 33316", R.drawable.fifthteenthst_fisheries));
    locations.add(new List("Shooters Waterfront","Laid-back spot on the Intracoastal Waterway offering food, drinks, live music & water views.","3033 NE 32nd Ave, Fort Lauderdale, FL 33308",R.drawable.shooterswaterfront ));
    locations.add(new List("OCEAN2000", "Ocean views from the veranda & menu of American dishes with Latin flair are highlights at this spot.", "2000 N Ocean Blvd, Fort Lauderdale, FL 33305", R.drawable.oceans2000));
    locations.add(new List("Blue Moon Fish Co.","Foodies flock to this upmarket fish house with a romantic vibe, outdoor deck & Sunday buffet brunch.","4405 W E Tradewinds Ave, Lauderdale-By-The-Sea, FL 33308",R.drawable.bluemoonfish));
    locations.add(new List("Two Georges","Lively, multiroomed dockside spot offering seafood, cocktails, live music & Intracoastal views.","1754 SE 3rd Ct, Deerfield Beach, FL 33441",R.drawable.twogeorges));
    locations.add(new List("The Whale's Rib","Seafood & \"whale\" fries are hot items at this bustling beach cafe/bar with old-time Florida flavor. Was featured on the Food Network","2031 NE 2nd St, Deerfield Beach, FL 33441",R.drawable.whalesrib));
    locations.add(new List("Ruth's Chris Steak House", "Outpost of upmarket steakhouse chain known for sizzling, butter-topped beef in an elegant setting", "2525 N Federal Hwy, Fort Lauderdale, FL 33305" ,R.drawable.ruthschrissteak));
    locations.add(new List("The Capital Grille", "Outpost of the upscale steakhouse chain offers classic American fare & a clubby, refined setting.", "2430 E Sunrise Blvd, Fort Lauderdale, FL 33304", R.drawable.capitalgrille ));
    locations.add(new List("Chima Steakhouse", "Posh, stylish venue for meats carved tableside, ample salad bar, outdoor bar & weeknight happy hour.", "2400 E Las Olas Blvd, Fort Lauderdale, FL 33301", R.drawable.chimasteak));
    locations.add(new List("Morton's The Steakhouse", "Upscale chain for aged prime beef, seafood & other traditional steakhouse fare in a clubby space.", "500 E W Broward Blvd #127, Fort Lauderdale, FL 33394" ,R.drawable.mortonssteak));
    locations.add(new List("Pampa Gaucho Steakhouse","Known as the best Brazilian Steakhouse in all of South Florida", "4490 N Federal Hwy, Lighthouse Point, FL 33064", R.drawable.truluckssteak ));
    // Create a ArrayAdapter from the made ListAdapter (custom ArrayAdapter) The adapter will set to display the
    // contents of the locations list
    ListAdapter adapter =
            new ListAdapter(getActivity(), locations);

    // Find the ListView object (in xml list_view) named list.
    ListView listView = (ListView) rootView.findViewById(R.id.list);

    //Make the ListView use the ArrayAdapter(adapter) we created above, so the
    //ListView will display list items for each location in the list of locations.
    listView.setAdapter(adapter);


    address.setOnClickListener(new Intent() {

        @Override
        public void onClick(View v) {
            Intent geoIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(("geo:0,0?q=" + address.getText().toString())));
            startActivity(geoIntent);
        }
    });


    return rootView;
}

`

Ответы [ 2 ]

0 голосов
/ 05 октября 2018

Intent не имеет функции с именем onClick.Возможно, вы захотите передать другой объект в setOnClickListener.

0 голосов
/ 05 октября 2018

Intent не имеет функции с именем onClick.Возможно, вы захотите передать другой объект в setOnClickListener.Вы должны попробовать OnClickListener пакета View

...