Skip to main content
Glama

android_generate_list_adapter

Efficiently create Android RecyclerView adapters and layouts for DHIS2-style lists, with options for shimmer placeholders, pull-to-refresh, and sticky headers to enhance UI functionality.

Instructions

Generate Android RecyclerView adapter and layout for DHIS2-style lists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
adapterNameNoAdapter class name
itemLayoutNoViewBinding layout base name (e.g., item_data_element)
pullToRefreshNoInclude pull-to-refresh pattern
shimmerNoInclude shimmer placeholder pattern
stickyHeadersNoInclude sticky headers in list

Implementation Reference

  • MCP tool handler that receives arguments, calls generateAndroidListAdapter, and returns the generated Android RecyclerView adapter code as text content.
    case 'android_generate_list_adapter': const aListArgs = args as any; const aList = generateAndroidListAdapter(aListArgs); return { content: [{ type: 'text', text: aList }] };
  • Core implementation function that generates Kotlin RecyclerView.Adapter code and corresponding XML item layout for Android list display.
    export function generateAndroidListAdapter(args: any): string { const { adapterName = 'DataElementAdapter', itemLayout = 'item_data_element' } = args; return `# Android RecyclerView Adapter: ${adapterName} ## Adapter (Kotlin) \`\`\`kotlin class ${adapterName}(private val items: MutableList<DataElement>) : RecyclerView.Adapter<${adapterName}.ViewHolder>() { class ViewHolder(val binding: ${camelToPascal(itemLayout)}Binding) : RecyclerView.ViewHolder(binding.root) override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) val binding = ${camelToPascal(itemLayout)}Binding.inflate(inflater, parent, false) return ViewHolder(binding) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val item = items[position] holder.binding.name.text = item.displayName holder.binding.type.text = item.valueType } override fun getItemCount(): Int = items.size } \`\`\` ## Item Layout (XML) \`\`\`xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <TextView android:id="@+id/name" android:layout_width="match_parent" android:layout_height="wrap_content" android:textStyle="bold"/> <TextView android:id="@+id/type" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> \`\`\` `;
  • Tool permission registration mapping 'android_generate_list_adapter' to 'canUseMobileFeatures' permission check.
    ['android_generate_list_adapter', 'canUseMobileFeatures'],

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Dradebo/dhis2-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server