In Elements.xml for custom action, use $ListId:Lists/xxx; as RgistrationId, replace xxx with the static name of your list. e.g.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="RibbonTest"
Location="CommandUI.Ribbon"
RegistrationId="$ListId:Lists/MyList;"
RegistrationType="List"
Sequence="1">
Please note that this approach only works in sandboxed solution, it doesn't work in a farm solution.