MANILA — President Trump confirmed on Tuesday that he had appealed to President Xi Jinping of China on behalf of three basketball players from the University of California, Los Angeles, who were arrested last week in Hangzhou, China, on suspicion of shoplifting.

“I had a great conversation with President Xi,” Mr. Trump told reporters as he was leaving the Philippines after a 12-day trip to Asia. “What they did was unfortunate. You know, you’re talking about very long prison sentences. They do not play games.”

In China, where the justice system has a very high conviction rate, theft can bring punishment ranging from a few days to years in prison.

Mr. Trump said he hoped the Chinese president would help the players: LiAngelo Ball, a freshman guard; and Cody Riley and Jalen Hill, both freshman forwards. He emphasized that it was a “very, very rough situation, with what happened to them.”

The three men were arrested this past Tuesday, accused of stealing designer sunglasses from a Louis Vuitton store next to their hotel in Hangzhou, in eastern China, where they were planning to play in a tournament. They were released on bail last Wednesday but were reportedly confined to the hotel. (Playing without the three freshmen, U.C.L.A. defeated Georgia Tech, 63-60, in Shanghai on Friday.)

Mr. Trump has made much of his personal rapport with Mr. Xi, who hosted a lavish state visit last week for the president in Beijing. The two leaders met again at an economic summit meeting on Sunday in Vietnam, where Mr. Trump raised the case.

“He’s been terrific,” the president said. “President Xi has been terrific on that subject.”

Mr. Trump, who said he had learned of the case only at the weekend, said he hoped the players would be able to return to the United States soon. U.C.L.A. said in a statement that it was aware of the situation and was cooperating with the local authorities.

The most high-profile of the detained players is Mr. Ball, the middle of the three “Ball Brothers.” The eldest, Lonzo, plays for the Los Angeles Lakers, and the youngest, LaMelo, is a high schooler who has committed to play at U.C.L.A. Their father, LaVar, has become a public figure, and has started a sports-apparel company, Big Baller Brand. Facebook has been filming a reality series focusing on them, “Ball in the Family.”

The U.C.L.A. team’s trip to China had been seen as a way to raise the profile of the university in that country, possibly attracting students who have well-to-do parents and who want to study abroad. Many American universities in recent years have increasingly relied on tuition payments from foreign students.