在数组列表中映射意图

我正在创建一个应用程序,它是一个城市的导游。我在每个类别中都有诸如食物、景点等类别,我使用自定义数组适配器制作了一个列表视图。数组列表中包含图像、每个地方的描述和地址。我正在尝试为地址部分设置一个 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 

烙印99
浏览 161回答 2
2回答

慕斯王

Intent 没有名为 onClick 的函数。您可能希望将不同的对象传递给 setOnClickListener。

翻翻过去那场雪

Intent 没有名为 onClick 的函数。您可能希望将不同的对象传递给 setOnClickListener。您应该尝试查看包的 OnClickListener
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java